Skip Navigation

All hooks listed in this API are available for WooCommerce Multilingual (WCML) versions >= 3.5

Multi-currency Feature

wcml_custom_prices_strings – Modify strings used in the section for setting the prices in other currencies manually

availability:
WCML Version: 3.8
description:

Modify strings used in the Set prices in other currencies manually section.

type:
filter
category:
Multi-currency Feature
parameters:
add_filter( 'wcml_custom_prices_strings', 'the_callback_function', 10, 2 );

There are two parameters passed to this filter:

$strings
(array) The string array used in the custom price section. It looks like the following:
array(
'not_set' => sprintf( __( 'Multi-currency is enabled but no secondary currencies have been set. %sAdd secondary currencies%s.',
'woocommerce-multilingual' ), '', '' ),
'calc_auto' => __( 'Calculate prices in other currencies automatically', 'woocommerce-multilingual' ),
'see_prices' => __( 'Click to see the prices in the other currencies as they are currently shown on the front end.', 'woocommerce-multilingual' ),
'show' => __( 'Show', 'woocommerce-multilingual' ),
'hide' => __( 'Hide', 'woocommerce-multilingual' ),
'set_manually' => __( 'Set prices in other currencies manually', 'woocommerce-multilingual' ),
'enter_prices' => __( 'Enter prices in other currencies', 'woocommerce-multilingual' ),
'hide_prices' => __( 'Hide prices in other currencies', 'woocommerce-multilingual' ),
'det_auto' => __( 'Determined automatically based on exchange rate', 'woocommerce-multilingual' ),
'_regular_price' => __( 'Regular Price', 'woocommerce-multilingual' ),
'_sale_price' => __( 'Sale Price', 'woocommerce-multilingual' ),
'schedule' => __( 'Schedule', 'woocommerce-multilingual' ),
'same_as_def' => __( 'Same as default currency', 'woocommerce-multilingual' ),
'set_dates' => __( 'Set dates', 'woocommerce-multilingual' ),
'collapse' => __( 'Collapse', 'woocommerce-multilingual' ),
'from' => __( 'From…', 'woocommerce-multilingual' ),
'to' => __( 'To…', 'woocommerce-multilingual' ),
'enter_price' => __( 'Please enter in a value less than the regular price', 'woocommerce-multilingual' )
)
$product_id
(integer) The ID of an original product.
hook example usage:

Example

/**
 * Add this code to the functions.php file of your theme.
 */

add_filter( 'wcml_custom_prices_strings', 'set_labels_for_price_fields', 10, 2 );
function set_labels_for_price_fields( $strings, $product_id ){

    // Change the default text "Show" to "Display"
    $strings[ 'show' ] = __( 'Display', 'woocommerce-multilingual' ); 

    return $strings;

}
Back to the top

wcml_is_cache_enabled_for_switching_currency – Add the currency code to the URL

availability:
WCML Version: 4.3.3
description:

This filter adds ?wcmlc={currency_code} to the URL, which specifies a query string with the currency code. This is useful when your site has cache enabled and doesn’t show currency changes correctly.

type:
filter
category:
Multi-currency Feature
parameters:
add_filter( 'wcml_is_cache_enabled_for_switching_currency', 'the_callback_function', 10, 1 );

There is only one parameter passed to this filter:

$enabled

(bool) Set to true to enable the filter.
hook example usage:

Example

/**
* Enable the query string argument on currency change.
*/
add_filter( 'wcml_is_cache_enabled_for_switching_currency', '__return_true' );

Back to the top

wcml_geolocation_get_user_country – Allow the overriding of the WCML geolocated country.

availability:
WCML Version: 4.11.0
description:

Allow the overriding of the WCML geolocated country.

type:
filter
category:
Multi-currency Feature
parameters:
$userCountry
(string) Billing address used if set otherwise geolocation country.
$allUserCountries
(array) {
@key $billing
(string) The billing address country
@key $shipping
(string) The shipping address country
@key $geolocation

(string) The geolocation country

}

hook example usage:
// Always use the shipping address if it's available
add_filter( 'wcml_geolocation_get_user_country', function( $userCountry, $allCountries ) {
    return ! empty( $allCountries['shipping'] ) ? $allCountries['shipping'] : $userCountry;
}, 10, 2 );
Back to the top

wcml_user_store_strategy – Allows overriding the storage strategy. The default storage is wc-session, and the only current alternative is cookie.

availability:
WCML Version: 4.11.0
description:

Allows overriding the storage strategy. The default storage is wc-session, and the only current alternative is cookie.

type:
filter
category:
Multi-currency Feature
parameters:
‘wc-session’
(string) Storage strategy
$key
(string) The key operating the storage
hook example usage:
// Use Cookie instead of WCSession
add_filter( 'wcml_user_store_strategy', function ( $strategy, $key ) {
	return 'cookie';
}, 10, 2 );
Back to the top

wcml_rounded_price – Filter second currency prices after applying rounding rules

availability:
WCML Version: 4.0.0
description:
  • Filter second currency prices after applying rounding rules.
  • These rules are set on the WooCommerce -> WooCommerce Multilingual page, under the Multi-currency tab.
type:
filter
category:
Multi-currency Feature
parameters:
add_filter( 'wcml_rounded_price', 'the_callback_function', 10, 2 );

There are two parameters passed to this filter:

$price
(integer) The price after applying rounding rules.
$currency
(string) The second currency code, e.g. “USD”, “EUR”, etc.
hook example usage:

Example

/*
 * Add this code to the functions.php file of your theme.
 *
 * Assume: 
 * USD = the default currency
 * EUR = the second currency
 */
  
add_filter( 'wcml_rounded_price', 'wcmlhook_rounded_price', 10, 2 );

function wcmlhook_rounded_price( $price, $currency ) {
	if ( 'EUR' == $currency ) {
		$price = $price + 0.99; // Add 99 cents to all rounded prices
	}

	return $price;
}

Back to the top

wcml_currencies_without_cents – Filter the array of currencies without cents

availability:
WCML Version: 4.0.0
description:
  • Filter the array of currencies without cents.
  • By default, this array includes the following currencies:
    array('JPY', 'TWD', 'KRW', 'BIF', 'BYR', 'CLP', 'GNF', 'ISK', 'KMF', 'PYG', 'RWF', 'VUV', 'XAF', 'XOF', 'XPF');
type:
filter
category:
Multi-currency Feature
parameters:
add_filter( 'wcml_currencies_without_cents', 'the_callback_function' );

There is only one parameter passed to this filter: currencies.

$currencies
(array) The array of currencies without cents.
hook example usage:

Example

add_filter( 'wcml_currencies_without_cents', 'wcmlhook_currencies_without_cents' );
function wcmlhook_currencies_without_cents( $currencies ) {
	$currencies[] = 'ABC' // Add a new currency to this array 
	return $currencies;
}

Back to the top

wcml_product_custom_prices – Filter custom prices set for products

availability:
WCML Version: 3.8.2
description:

Filter custom prices set for products.

type:
filter
category:
Multi-currency Feature
parameters:
add_filter( 'wcml_product_custom_prices', 'the_callback_function', 10, 3 );

There are three parameters passed to this filter:

$custom_prices
(array) The custom price array. Their keys include:
'_price', '_regular_price', '_sale_price',
'_min_variation_price',
'_max_variation_price',
'_min_variation_regular_price', '_max_variation_regular_price',
'_min_variation_sale_price',
'_max_variation_sale_price'
$product_id
(integer) The product ID.
$currency
(string) The second currency whose custom prices are being saved, e.g. “USD”, “EUR”, etc.

 

hook example usage:

Example

/*
 * Add this code to the functions.php file of your theme.
 *
 * Assume: 
 * EUR = the default currency
 * USD = the second currency
 */
 
add_filter( 'wcml_product_custom_prices', 'change_product_custom_prices', 10, 3 );

function change_product_custom_prices( $custom_prices, $product_id, $currency ) {

	// Change all custom prices in USD to 99 
	if ( 'USD' == $currency ) {
		$custom_prices[ '_price' ] = 99;
	}

	return $custom_prices; 
}
Back to the top

wcml_switch_currency – Run actions after the client currency for the front end is switched via AJAX requests.

availability:
WCML Version: 3.5
description:

Run your custom functions right after the client currency for the front end is switched via AJAX requests.

type:
action
category:
Multi-currency Feature
parameters:
add_action( 'wcml_switch_currency', 'the_callback_function', 10, 1 );

There is one parameter being passed to this action: new_currency.

$new_currency
(string) The new currency code is switched to, e.g. “USD”, “EUR”, etc.
hook example usage:

Example

add_action( 'wcml_switch_currency', 'my_custom_action', 10, 1 );
function my_custom_action( $new_currency ) {
	// my custom action
}
Back to the top

wcml_custom_prices_fields_labels – Add custom price field labels to products

availability:
WCML Version: 3.8
description:
  • Add custom price field labels to products.
  • These fields are displayed in the Set prices in other currencies manually section when editing/creating original products.
  • To add custom price fields, see the wcml_custom_prices_fields hook.
type:
filter
category:
Multi-currency Feature
parameters:
add_filter( 'wcml_custom_prices_fields_labels', 'the_callback_function', 10, 2 );

There are two parameters passed to this filter:

$labels
(array) The custom price field label array.
$product_id
(integer) The ID of an original product.
hook example usage:

Use the example code provided below to get results shown in the following screenshot.

custom-price-fields

Example

/*
 * Add this code to the functions.php file of your theme.
 */
add_filter( 'wcml_custom_prices_fields',  'add_custom_price_fields', 10, 2 );
function add_custom_price_fields( $fields, $product_id ) {
    
    // Add a new custom price field 
    $fields[] = '_sign_up_fee'; 

    return $fields;

}


add_filter( 'wcml_custom_prices_fields_labels', 'set_labels_for_price_fields', 10, 2 );
function set_labels_for_price_fields( $labels, $product_id ){

    // Edit the label of a custom price field
    $labels[ '_sign_up_fee' ] = __( 'Sign-up Fee', 'woocommerce-multilingual' ); 

    return $labels;

}
Back to the top

wcml_custom_prices_fields – Add additional custom price fields to products

availability:
WCML Version: 3.8
description:
  • Add additional custom price fields to products.
  • These fields are displayed in the Set prices in other currencies manually section when editing/creating original products.
  • To add custom price field labels, see the wcml_custom_prices_fields_labels hook.
type:
filter
category:
Multi-currency Feature
parameters:
add_filter( 'wcml_custom_prices_fields', 'the_callback_function', 10, 2 );

There are two parameters passed to this filter:

$fields
(array) The custom price field array.
$product_id
(integer) The ID of an original product.
hook example usage:

Use the example code provided below to get results shown in the following screenshot.

custom-price-fields

Example

/*
 * Add this code to the functions.php file of your theme.
 */
add_filter( 'wcml_custom_prices_fields',  'add_custom_price_fields', 10, 2 );
function add_custom_price_fields( $fields, $product_id ) {
    
    // Add a new custom price field 
    $fields[] = '_sign_up_fee'; 

    return $fields;

}


add_filter( 'wcml_custom_prices_fields_labels', 'set_labels_for_price_fields', 10, 2 );
function set_labels_for_price_fields( $labels, $product_id ){

    // Edit the label of a custom price field
    $labels[ '_sign_up_fee' ] = __( 'Sign-up Fee', 'woocommerce-multilingual' ); 

    return $labels;

}
Back to the top

wcml_multi_currency_ajax_actions – Add or remove the AJAX actions that need our multi-currency filters

availability:
WCML Version: 3.1
description:

Add or remove the AJAX actions that need our multi-currency filters.

type:
filter
category:
Multi-currency Feature
parameters:
add_filter( 'wcml_multi_currency_ajax_actions', 'the_callback_function', 10, 1 );

There is only one parameter passed to this filter: ajax_actions.

$ajax_actions
(array) The array including AJAX actions.
hook example usage:

Example

/**
 * Add this code to the functions.php file of your theme.
 */
add_filter( 'wcml_multi_currency_ajax_actions', 'add_action_to_multi_currency_ajax', 10, 1 );

function add_action_to_multi_currency_ajax( $ajax_actions ) {

    $ajax_actions[] = 'ux_quickview'; // Add a AJAX action to the array
    return $ajax_actions;

}
Back to the top

wcml_load_multi_currency_in_ajax – Define whether or not the multi-currency filters for AJAX actions are loaded

availability:
WCML Version: 3.9.2
description:

This is a filter used to define whether or not the multi-currency filters for AJAX actions are loaded.

type:
filter
category:
Multi-currency Feature
parameters:
add_filter( 'wcml_load_multi_currency_in_ajax', 'the_callback_function', 10, 1 );

There is only one parameter passed to this filter: load.

$load
(bool) The boolean value to define whether or not to load AJAX actions.
hook example usage:

Example

/**
 * Add this code to the functions.php file of your theme.
 */
add_filter( 'wcml_load_multi_currency_in_ajax', 'do_not_load_multi_currency_in_ajax', 10, 1 );

function do_not_load_multi_currency_in_ajax( $load ) {

    if ( is_checkout() ) { 
        $load = false; // If this is the checkout page, do not load multi-currency filters in AJAX actions
    }

    return $load;

}
Back to the top

wcml_update_custom_prices_values – Filter the custom prices for the second currency before saving them

availability:
WCML Version: 3.8
description:

Filter the custom prices for the second currency before saving them.

type:
filter
category:
Multi-currency Feature
parameters:
add_filter( 'wcml_update_custom_prices_values', 'the_callback_function', 10, 2 );

There are two parameters passed to this filter:

$prices
(array) The custom price array looks like the following:
array(
'_regular_price' => $regular_price,
'_sale_price' => $sale_price,
'_wcml_schedule' => $schedule,
'_sale_price_dates_from' => $date_from,
'_sale_price_dates_to' => $date_to )
$currency
(string) The second currency whose custom prices are being saved, e.g. “USD”, “EUR”, etc.
hook example usage:

Example

/*
 * Add this code to the functions.php file of your theme.
 *
 * Assume: 
 * EUR = the default currency
 * USD = the second currency
 */
add_filter( 'wcml_update_custom_prices_values',  'update_custom_prices_values', 10, 2 );


function update_custom_prices_values( $prices, $currency ){

    if( 'USD' == $currency ){
    	// Set the fixed USD custom sale price for all products when saving 
        $prices[ '_sale_price' ] = 49;
    }

    return $prices;

}
Back to the top

wcml_client_currency – Filter the currency set by the user on the front-end

availability:
WCML Version: 3.5
description:

Filter the currency set by the user on the front-end.

type:
filter
category:
Multi-currency Feature
parameters:
add_filter( 'wcml_client_currency', 'the_callback_function', 10, 1 );

There is only one parameter passed to this filter: currency.

$currency
(string) The code of the currency used on the front-end, e.g. “USD”, “EUR”, etc.
hook example usage:

Example

 /**
 * Add this code to the functions.php file of your theme.
 */
add_filter( 'wcml_client_currency', 'modify_client_currency', 10, 1 );
 
function modify_client_currency( $currency ) {
    return 'USD'; 
} 
Back to the top

wcml_exchange_rates – Filter the exchange rates used by WooCommerce Multilingual

availability:
WCML Version: 3.5
description:

Filter the exchange rates used by WooCommerce Multilingual.

type:
filter
category:
Multi-currency Feature
parameters:
add_filter( 'wcml_exchange_rates', 'the_callback_function', 10, 1 );

There is only one parameter passed to this filter: exchange_rates.

$exchange_rates
(array) The array includes your site currencies’ rates against the default currency.
hook example usage:

Example

/**
 * Add this code to the functions.php file of your theme.
 *
 * Assume: 
 * EUR = the default currency
 * USD = the second currency
 * 1.2 = the exchange rate EUR / USD  
 */
add_filter( 'wcml_exchange_rates', 'filter_exchange_rates', 10, 1 );

function filter_exchange_rates( $exchange_rates ) {
	$exchange_rates['USD'] = 1.5; // Change the rate EUR / USD to 1.5
	return $exchange_rates; 
}
Back to the top

wcml_formatted_price – Convert a default currency price to the selected currency, using the correct format.

availability:
WCML Version: 3.5
description:

Convert a default currency price to the selected currency, using the correct format.

type:
filter
category:
Multi-currency Feature
parameters:
apply_filters( 'wcml_formatted_price', integer/float $price, string $currency )
$price
(integer/float) (Required) The raw price in the default currency.
$currency
(string) (Optional) The currency code you want to convert the price into, e.g. “USD”, “EUR”, etc. If this parameter is not set, the current currency used on the front-end will be used.
hook example usage:

Example

/*
Assume: 
 * EUR = the default currency
 * USD = the second currency
 * 1.2 = the exchange rate EUR / USD 
*/ 

$price = 1234.56;
$currency = 'USD';
$formatted_price = apply_filters( 'wcml_formatted_price', $price, $currency );

echo $formatted_price; // Return $1,481.47
Back to the top

wcml_price_currency – Get the current currency on the front end

availability:
WCML Version: 3.5
description:
  • Get the current currency set on the front-end.
  • This filter is available on the front-end.
type:
filter
category:
Multi-currency Feature
parameters:
apply_filters( 'wcml_price_currency', mixed $empty_value )
$empty_value
(mixed) (Required) Normally, this is the value the filter will be modifying. We are not filtering anything here so you should set this to NULL. This argument allows the filter’s function to receive the full list of arguments.
hook example usage:

A basic example

$current_currency = apply_filters('wcml_price_currency', NULL );
Back to the top

wcml_set_client_currency – Run actions after the client currency for the front-end is set.

availability:
WCML Version: 3.5
description:

Run your custom functions right after the client currency for the front-end is set.

type:
action
category:
Multi-currency Feature
parameters:
add_action( 'wcml_set_client_currency', 'the_callback_function', 10, 1 );

There is one parameter being passed to this action: currency.

$currency
(string) The currency code is being set in the front-end, e.g: “USD”, “EUR”, etc.
hook example usage:

Example

add_action( 'wcml_set_client_currency', 'my_custom_action', 10, 1 );
function my_custom_action( $new_currency ) {
	// my custom action
}
Back to the top

wcml_after_custom_prices_block – Run actions after generating the custom price block on the WooCommerce native product editor.

availability:
WCML Version: 3.8.1
description:
  • Run actions after generating the custom price block on the WooCommerce native product editor.
  • This action is triggered when creating or editing the original products only.
type:
action
category:
Multi-currency Feature
parameters:
add_action( 'wcml_after_custom_prices_block', 'the_callback_function', 10, 1 );

There is one parameter being passed to this action:

$product_id
(integer | string) The ID of editing product OR the string value new if the product is being created.
hook example usage:

Example

add_action( 'wcml_after_custom_prices_block', 'my_custom_action', 10, 1 );

function my_custom_action( $product_id ) {

	// my custom action

}
Back to the top

wcml_before_multi_currency_ui – Run actions before generating the Multi-currency tab in the WPML -> Woocommerce Multilingual screen.

availability:
WCML Version: 3.8.1
description:

Run actions before generating the Multi-currency tab in the WPML -> Woocommerce Multilingual screen.

type:
action
category:
Multi-currency Feature
parameters:
add_action( 'wcml_before_multi_currency_ui', 'the_callback_function' );

This action has no parameter.

hook example usage:

Example

add_action( 'wcml_before_multi_currency_ui', 'my_custom_action' );

function my_custom_action() {

	// my custom action

}
Back to the top

wcml_after_save_custom_prices – Run actions after saving custom prices on the WooCommerce native product editor.

availability:
WCML Version: 3.8.1
description:
  • Run actions after saving custom prices on the WooCommerce native product editor.
  • This action is triggered when creating or editing the original products only.
type:
action
category:
Multi-currency Feature
parameters:
add_action( 'wcml_after_save_custom_prices', 'the_callback_function', 10, 1 );

There is one parameter being passed to this action:

$product_id
(integer) The ID of original product.
hook example usage:

Example

add_action( 'wcml_after_save_custom_prices', 'my_custom_action', 10, 1 );

function my_custom_action( $product_id ) {

	// my custom action

}
Back to the top

wcml_raw_price_amount – Convert the raw price in the default currency into the selected currency

availability:
WCML Version: 3.5
description:
  • Convert the raw price in the default currency into the selected currency.
  • This filter should be used for filtering product/variations prices in general.
  • It is available on the front-end.

This filter is applied to the custom fields of products and variations that are used for prices (when they are read from the database):

  • _price
  • _regular_price
  • _sale_price
  • _min_variation_price
  • _min_variation_price_regular_price
  • _mix_variation_price_sale_price
  • _max_variation_price
  • _max_variation_price_regular_price
  • _max_variation_price_sale_price
type:
filter
category:
Multi-currency Feature
parameters:
apply_filters( 'wcml_raw_price_amount', integer/float $price, string $currency )
$price
(integer/float) (Required) The raw price in the default currency.
$currency
(string) (Optional) The currency code you want to convert the price into, e.g. “USD”, “EUR”, etc. If this parameter is not set, the current currency used on the front-end will be used.
hook example usage:

Example

/*
Assume: 
 * USD = the default currency
 * EUR = the second currency
 * 0.8 = the exchange rate USD / EUR 
*/ 

$price = 100; 
$currency = "EUR";
$new_price = apply_filters('wcml_raw_price_amount', $price, $currency);

echo $new_price; // Return 80 
Back to the top

wcml_currency_switcher – Run actions when the currency switcher widget is being generated.

availability:
WCML Version: 3.9
description:

Run actions when the currency switcher widget is being generated.

type:
action
category:
Multi-currency Feature
parameters:
add_action( 'wcml_currency_switcher', 'the_callback_function' );

This action has no parameters.

hook example usage:

Example

add_action( 'wcml_currency_switcher', 'my_custom_action' );

function my_custom_action() {

	// my custom action

}
Back to the top

wcml_product_price_by_currency – Get the product price in selected currency.

availability:
WCML Version: 3.9
description:
  • This hook returns the custom price if entered. Otherwise, it returns the price based on the set exchange rate.
  • This hook works only on the front-end.
type:
filter
category:
Multi-currency Feature
parameters:
apply_filters( 'wcml_product_price_by_currency', integer $product_id, string $currency )
$product_id
(integer) (Required) The product ID
$currency
(string) (Required) The currency code you want to get the price for, e.g. “USD”, “EUR”, etc.
hook example usage:

Example

 // Get the EUR price of the product ID = 80 
$product_id = 80; 
$currency = 'EUR'; 
echo apply_filters( 'wcml_product_price_by_currency', $product_id, $currency );
 
Please note: Multicurrency code is not always loaded. If you find that this filter is not working, please take a look at the wcml_load_multi_currency_in_ajax hook.
Back to the top

Inserting Content

wcml_product_content_fields – Add or remove custom fields in the WCML Translation Editor

availability:
WCML Version: 3.6
description:

Add or remove custom fields in the WCML Translation Editor.

type:
filter
category:
Inserting Content
parameters:
add_filter( 'wcml_product_content_fields', 'the_callback_function', 10, 2 );

There are two parameters passed to this filter:

$fields
(array) The custom field array.
$product_id
(integer) The ID of an original product.
hook example usage:

Example

/*
 * Add this code to the functions.php file of your theme.
 */
add_filter( 'wcml_product_content_fields', 'add_custom_fields_wcml_editor', 10, 2 );

function add_custom_fields_wcml_editor ( $fields, $product_id ) {

	// Add the 'new_button_label' field to WCML Translation Editor 
	$fields[] = 'new_button_label'; 
	return $fields;
}
Back to the top

wcml_product_content_label – Modify custom field names in the WCML Translation Editor

availability:
WCML Version: 3.6
description:

Modify custom field names in the WCML Translation Editor.

type:
category:
Inserting Content
parameters:
add_filter( 'wcml_product_content_label', 'the_callback_function', 10, 2 );

There are two parameters passed to this filter:

$meta_key
(string) The custom field key.
$product_id
(integer) The ID of an original product.
hook example usage:

Example

/*
 * Add this code to the functions.php file of your theme.
 */

add_filter( 'wcml_product_content_label', 'change_field_label', 10, 2 );

function change_field_label( $meta_key, $product_id ) {

	// Change the label of 'new_button_label' field in WCML Translation Editor 

	if ( $meta_key == 'new_button_label' ) {
		return __( 'Translate New Button Label', 'textdomain' );
	}

	return $meta_key;
}
Back to the top

wcml_after_duplicate_product – Run actions after duplicating a product.

availability:
WCML Version: 3.5
description:

Run actions after duplicating a product.

type:
action
category:
Inserting Content
parameters:
add_action( 'wcml_after_duplicate_product', 'the_callback_function', 10, 2 );

There are two parameters being passed to this action:

$new_id
(integer) The ID of new product.
$post_to_duplicate
(object) The original post data to duplicate.
hook example usage:

Example

add_action( 'wcml_after_duplicate_product', 'my_custom_action', 10, 2 );

function my_custom_action( $original_product_id, $new_id, $post_to_duplicate ) {

	// my custom action

}
Back to the top

Miscellaneous

wcml_is_attributes_page – Add filters to check if the current product page is an attribute page

availability:
WCML Version: 3.8
description:

Add filters to check if the current product page is an attribute page. This is useful for WooCommerce extensions that have their own attribute pages.

type:
filter
category:
Miscellaneous
parameters:
add_filter( 'wcml_is_attributes_page', 'the_callback_function' );

There is one parameter passed to this filter:

$is_attribute_page
(bool) Whether or not the current page is an attribute page.
hook example usage:

Example

/**
 * This example is extracted from the Adventure Tours Theme compatibility class in the WCML code. 
 */
add_filter( 'wcml_is_attributes_page', 'is_attributes_page' );

function is_attributes_page( $is_attribute_page ){

    if( isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'product_attributes_extended' && isset( $_GET[ 'post_type' ] ) && $_GET[ 'post_type' ] == 'product' ){
        $is_attributes_page = true;
    }

    return $is_attributes_page;
}
Back to the top

wcml_current_gateway_language – Filter language for Gateway strings ( title, description, instructions )

availability:
WCML Version: 4.9.0
description:

Filter language for Gateway strings ( title, description, instructions )

type:
filter
category:
Miscellaneous
parameters:
$current_gateway_language
(string) Gateway string language
hook example usage:
add_filter( 'wcml_current_gateway_language', 'use_current_language_for_gateway_strings' );

public function use_current_language_for_gateway_strings( $current_gateway_language ){
    return apply_filters( 'wpml_current_language' );
}
Back to the top

wcml_new_order_admin_email_language – Set admin email language

availability:
WCML Version: 4.7.0
description:

Use this filter to set the language of the email sent to the administrator when a new order is placed or the status of an existing one changes.

type:
filter
category:
Miscellaneous
parameters:
apply_filters( 'wcml_new_order_admin_email_language', $admin_language, $recipient, $order_id )

There are three parameters being passed to this filter:

$admin_language
(string) The admin user language.
$recipient
(string) The admin user email.
$order_id
(integer) The order ID.
  • admin user language
  • $recipient admin user email
  • order id
hook example usage:

Example

add_filter( 'wcml_new_order_admin_email_language', 'use_order_language_for_new_order_admin_email', 10, 3 );

function use_order_language_for_new_order_admin_email( $admin_language, $recipient, $order_id ){
    $order_language = get_post_meta( $order_id, 'wpml_language', true );

    return $order_language ? $order_language : $admin_language;
}
Back to the top

translate_shipping_methods_in_package – Can be used for shipping methods translations

availability:
WCML Version: 4.6.5
description:

Can be used for shipping methods translations.

type:
filter
category:
Miscellaneous
parameters:
apply_filters( 'wcml_translate_shipping_method_in_package', true, $key, $method )

There are two parameters being passed to this filter:

$key
The method key.
$method
The method object.
hook example usage:
Back to the top

wcml_gui_additional_box_html – Add additional fields to translate in WCML Translation Editor.

availability:
WCML Version: 3.8.1
description:
type:
action
category:
Miscellaneous
parameters:
add_action( 'wcml_gui_additional_box_html', 'the_callback_function', 10, 3 );

There are three parameters being passed to this action:

$obj
(object) The translation job object.
$product_id
(integer) The ID of original product.
$data
(array) The translation job data array.
hook example usage:

Example

add_action( 'wcml_gui_additional_box_html', 'my_custom_action', 10, 3 );

function my_custom_action( $obj, $product_id, $data ) {

	// my custom action

}
Back to the top

wcml_variation_term_taxonomy_ids – Filter the IDs of variation's taxonomies that a term belongs to

availability:
WCML Version: 3.5
description:
  • Filter the IDs of variation’s taxonomies that a term belongs to.
  • Some WooCommerce extensions add their own custom variation product post types like WooCommerce Subscriptions. This filter is used in the function to check whether or not a product is variable. It collects all variation’s taxonomy IDs a term belongs to, for variable products.
type:
filter
category:
Miscellaneous
parameters:
add_filter( 'wcml_variation_term_taxonomy_ids', 'the_callback_function' );

There is only one parameter passed to this filter: term_taxonomy_ids.

$term_taxonomy_ids
(array) The array containing taxonomy term IDs of variable product types.
hook example usage:

Example

/**
 * This example is extracted from the WooCommerce Subscriptions compatibility class in the WCML code. 
 * This WooCommerce extension has its own variable product type called "variable-subscription"
 */

add_filter('wcml_variation_term_taxonomy_ids', 'add_wcml_variation_term_taxonomy_ids');

function add_wcml_variation_term_taxonomy_ids($get_variation_term_taxonomy_ids){
    global $wpdb;
    $get_variation_term_taxonomy_id = $wpdb->get_var("SELECT tt.term_taxonomy_id FROM $wpdb->terms AS t LEFT JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE t.slug = 'variable-subscription'");
    
    if(!empty($get_variation_term_taxonomy_id)){
        $get_variation_term_taxonomy_ids[] = $get_variation_term_taxonomy_id;    
    }
    
    return $get_variation_term_taxonomy_ids;
}
Back to the top

wcml_is_variable_product – Add filters to check if a product is variable

availability:
WCML Version: 3.8
description:

Add filters to check if a product is variable. This is useful for WooCommerce extensions that have their own variable product types.

type:
filter
category:
Miscellaneous
parameters:
add_filter( 'wcml_is_variable_product', 'the_callback_function', 10, 2 );

There are two parameters passed to this filter:

$is_variable
(bool) Whether or not the product is variable.
$product_id
(integer) The product ID.
hook example usage:

Example

/**
 * This example is extracted from the Adventure Tours compatibility class in the WCML code. 
 */

add_filter( 'wcml_is_variable_product', 'is_variable_tour', 10, 2 );

function is_variable_tour( $is_variable, $product_id ){
    $var_tour_meta = get_post_meta( $product_id, '_variable_tour', true );

    if( $is_variable && $var_tour_meta == 'yes' ){
        $is_variable = true;
    }elseif( $var_tour_meta == 'no' ){
        $is_variable = false;
    }

    return $is_variable;
}
Back to the top

wcml_register_endpoints_query_vars – Add new WooCommerce endpoints to be ready for translation with WooCommerce Multilingual

availability:
WCML Version: 3.8
description:

Add new WooCommerce endpoints to be ready for translation with WooCommerce Multilingual.

type:
filter
category:
Miscellaneous
parameters:
add_filter( 'wcml_register_endpoints_query_vars', 'the_callback_function', 10, 3 );

There are three parameters passed to this filter:

$query_vars
(array) The WordPress query var (endpoint) array.
$wc_vars
(array) The WooCommerce default endpoint array.
$obj
(object) The WCML_Endpoints object.

 

hook example usage:

Example

/*
 * Add this code to the functions.php file of your theme.
 * This is extracted from the WCML WC Subscriptions compatibility class. 
 */
 
add_filter('wcml_register_endpoints_query_vars', 'register_endpoint', 10, 3 );

function register_endpoint( $query_vars, $wc_vars, $obj ){

    // Add the translation for the custom "view-subscription" endpoint.
    $query_vars[ 'view-subscription' ] = $obj->get_endpoint_translation( 'view-subscription',  isset( $wc_vars['view-subscription'] ) ? $wc_vars['view-subscription'] : 'view-subscription' );

    return $query_vars;
}
Back to the top

wcml_localize_woocommerce_on_ajax – Run actions during WPML AJAX requests.

availability:
WCML Version: 3.9
description:

Run actions during WPML AJAX requests.

type:
action
category:
Miscellaneous
parameters:
add_action( 'wcml_localize_woocommerce_on_ajax', 'the_callback_function' );

This action has no parameters.

hook example usage:

Example

add_action( 'wcml_localize_woocommerce_on_ajax', 'my_custom_action' );

function my_custom_action() {

	// my custom action

}
Back to the top

wcml_not_display_single_fields_to_translate – Add or remove the custom fields that do not display in the WCML Translation Editor

availability:
WCML Version: 3.8
description:

Add or remove the custom fields that do not display in the WCML Translation Editor.

type:
filter
category:
Miscellaneous
parameters:
add_filter( 'wcml_not_display_single_fields_to_translate', 'the_callback_function', 10, 1 );

There is only one parameter passed to this filter: fields.

$fields
(array) The custom field array.
hook example usage:

Example

/**
 * Add this code to the functions.php file of your theme.
 */

add_filter( 'wcml_not_display_single_fields_to_translate', 'remove_single_custom_fields_to_translate', 10, 1 );

function remove_single_custom_fields_to_translate( $fields ) {
	
	// Remove the "my_custom_info" field from display in WCML Translation Editor 
	$fields[] = 'my_custom_info'; 
	return $fields;
}

 

Back to the top

wcml_wc_installed_pages – Add or remove the WooCommerce page option names used in WooCommerce Multilingual

availability:
WCML Version: 3.5
description:

Add or remove the WooCommerce page option names used in WooCommerce Multilingual.

type:
filter
category:
Miscellaneous
parameters:
add_filter( 'wcml_wc_installed_pages', 'the_callback_function', 10, 1 );

There is only one parameter passed to this filter: page_option_names.

$page_option_names
(array) The page option name array looks like the following:
array(
'woocommerce_shop_page_id',
'woocommerce_cart_page_id',
'woocommerce_checkout_page_id',
'woocommerce_myaccount_page_id'
)
hook example usage:

Example

/**
 * Add this code to the functions.php file of your theme.
 */
 
add_filter( 'wcml_wc_installed_pages', 'add_wc_installed_pages', 10, 1 );
 
function add_wc_installed_pages( $page_option_names ) {
     
    // A new page option name 
    $page_option_names[] = 'woocommerce_custom_page_id'; 
    return $page_option_names;
}
Back to the top

wcml_after_load_lock_fields_js – Run actions after loading the JavaScript code for locking fields on the translated product editor page

availability:
WCML Version: 3.8.1
description:

Run actions after loading the JavaScript code for locking fields on the translated product editor page (WooCommerce native editor).

type:
action
category:
Miscellaneous
parameters:
add_action( 'wcml_after_load_lock_fields_js', 'the_callback_function' );

This action has no parameter.

hook example usage:

Example

add_action( 'wcml_after_load_lock_fields_js', 'my_custom_action' );

function my_custom_action() {

	// my custom action

}
Back to the top

wcml_gui_additional_box_data – Add translation data for fields in custom sections of WCML Translation Editor

availability:
WCML Version: 3.8.1
description:
type:
filter
category:
Miscellaneous
parameters:
add_filter( 'wcml_gui_additional_box_data', 'the_callback_function', 10, 4 );

There are four parameters being passed to this filter:

$data
(array) The translation job data array.
$product_id
(integer) The ID of original product.
$translation
(object) The translation job object.
$target_language
(string) The language code of translated product.
hook example usage:

Example

add_filter( 'wcml_gui_additional_box_data', 'my_custom_action', 10, 4 );
 
function my_custom_action( $data, $product_id, $translation, $target_language ) {
 
    // my custom action
 
}
Back to the top

wcml_endpoint_permalink_filter – Filter endpoint values before getting permalinks

availability:
WCML Version: 3.8
description:

Filter endpoint values before getting permalinks.

type:
filter
category:
Miscellaneous
parameters:
add_filter( 'wcml_endpoint_permalink_filter', 'the_callback_function', 10, 2 );

There are two parameters passed to this filter:

$endpoint
(string) The endpoint value.
$key
(string) The endpoint key.
hook example usage:

Example

/*
 * Add this code to the functions.php file of your theme.
 * This is extracted from the WCML WC Subscriptions compatibility class. 
 */
 
add_filter( 'wcml_endpoint_permalink_filter', 'endpoint_permalink_filter', 10, 2) ;

function endpoint_permalink_filter( $endpoint, $key ){

    if( $key == 'view-subscription' ){
        return 'view-subscription';
    }

    return $endpoint;
}
Back to the top

Updating Content

wcml_js_lock_fields_input_names – Add or remove custom field input names that are locked on the WooCommerce native product editor of translated products

availability:
WCML Version: 3.8
description:

Add or remove custom field input names that are locked on the WooCommerce native product editor of translated products.

type:
filter
category:
Updating Content
parameters:
add_filter( 'wcml_js_lock_fields_input_names', 'the_callback_function' );

There is only one parameter passed to this filter:

$names
(array) The array including custom field input names.
hook example usage:

Example

/**
 * Add this code to the functions.php file of your theme.
 */
add_filter( 'wcml_js_lock_fields_input_names', 'add_js_lock_fields_input_names' );

function add_js_lock_fields_input_names( $names ){

	// Add 2 locked field input names
	$names[] = '_base_regular_price';
	$names[] = 'bto_style';

	return $names;
}
Back to the top

wcml_js_lock_fields_classes – Add or remove custom field classes that are locked on the WooCommerce native product editor of translated products

availability:
WCML Version: 3.8
description:

Add or remove custom field classes that are locked on the WooCommerce native product editor of translated products.

type:
filter
category:
Updating Content
parameters:
add_filter( 'wcml_js_lock_fields_classes', 'the_callback_function' );

There is only one parameter passed to this filter:

$classes
(array) The array including custom field classes.
hook example usage:

Example

/**
 * Add this code to the functions.php file of your theme.
 */
add_filter( 'wcml_js_lock_fields_classes', 'add_js_lock_fields_classes' );

function add_js_lock_fields_classes( $classes ){

	// Add 2 locked field classes
	$classes[] = '_per_product_pricing_bto';
	$classes[] = '_per_product_shipping_bto';

	return $classes;
}
Back to the top

wcml_js_lock_fields_ids – Add or remove custom field IDs that are locked on the WooCommerce native product editor of translated products

availability:
WCML Version: 3.8
description:

Add or remove custom field IDs that are locked on the WooCommerce native product editor of translated products.

type:
filter
category:
Updating Content
parameters:
add_filter( 'wcml_js_lock_fields_ids', 'the_callback_function' );

There is only one parameter passed to this filter:

$ids
(array) The array including custom field IDs.
hook example usage:

Example

/**
 * Add this code to the functions.php file of your theme.
 */
add_filter( 'wcml_js_lock_fields_ids', 'add_js_lock_fields_ids' );

function add_js_lock_fields_ids( $ids ){

	// Add 2 locked field IDs
	$ids[] = '_per_product_pricing_bto';
	$ids[] = '_per_product_shipping_bto';

	return $ids;
}
Back to the top

wcml_before_sync_product – Run actions before WCML syncs original products to their translated products.

availability:
WCML Version: 3.6.3
description:
type:
action
category:
Updating Content
parameters:
add_action( 'wcml_before_sync_product', 'the_callback_function', 10, 2 );

There are two parameters being passed to this action:

$original_product_id
(integer) The ID of original product.
$translated_product_id
(integer) The ID of translated product.
hook example usage:

Example

add_action( 'wcml_before_sync_product', 'my_custom_action', 10, 2 );

function my_custom_action( $original_product_id, $translated_product_id ) {

	// my custom action

}
Back to the top

wcml_after_duplicate_product_post_meta – Run actions after the post meta fields are being set for a duplicated product.

availability:
WCML Version: 3.5
description:

Run actions after the post meta fields are being set for a duplicated product.

type:
action
category:
Updating Content
parameters:
add_action( 'wcml_after_duplicate_product_post_meta', 'the_callback_function', 10, 3 );

There are three parameters being passed to this action:

$original_product_id
(integer) The ID of original product.
$translated_product_id
(integer) The ID of translated product.
$data
(array) The original product data.
hook example usage:

Example

add_action( 'wcml_after_duplicate_product_post_meta', 'my_custom_action', 10, 3 );

function my_custom_action( $original_product_id, $duplicated_product_id, $data ) {

	// my custom action

}
Back to the top

wcml_update_extra_fields – Run actions after the translated product fields are updated.

availability:
WCML Version: 3.5
description:

Run your custom functions right after the translated product fields are updated.

type:
action
category:
Updating Content
parameters:
add_action( 'wcml_update_extra_fields', 'the_callback_function', 10, 4 );

There are four parameters being passed to this action:

$original_product_id
(integer) The ID of original product.
$translated_product_id
(integer) The ID of translated product.
$translation_data
(array) The data of translated product.
$target_language
(string) The language code of translated product.
hook example usage:

Example

add_action( 'wcml_update_extra_fields', 'my_custom_action', 10, 4 );

function my_custom_action( $original_product_id, $translated_product_id, $translation_data, $target_language ) {

	// my custom action

}
Back to the top

wcml_before_sync_product_data – Run actions before WCML syncs data (images, taxonomies, variations, etc) from original products to their translations.

availability:
WCML Version: 3.7.0
description:
  • Run actions before WCML syncs data (images, taxonomies, variations, etc) from original products to their translations.
  • This action is called after wcml_before_sync_product.
type:
action
category:
Updating Content
parameters:
add_action( 'wcml_before_sync_product_data', 'the_callback_function', 10, 3 );

There are three parameters being passed to this action:

$original_product_id
(integer) The ID of original product.
$translated_product_id
(integer) The ID of translated product.
$target_language
(string) The language code of translated product.
hook example usage:

Example

add_action( 'wcml_before_sync_product_data', 'my_custom_action', 10, 3 );

function my_custom_action( $original_product_id, $translated_product_id, $target_language ) {

	// my custom action

}
Back to the top

Orders

wcml_should_translate_order_items – Allows the ability to override translating order items.

availability:
WCML Version: 4.11.0
description:

Allows the ability to override translating order items.

type:
filter
category:
Orders
parameters:
$translate_order_items
(bool) True if we should translate order items
$items
(WC_Order_Item[]) Order items
$order
(WC_Order) WC order
hook example usage:
add_filter( 'wcml_should_translate_order_items', function ( $translate_order_items, $items, $order ) {
	return false;
}, 10, 3 );
Back to the top

wcml_should_save_adjusted_order_item_in_language – Allows overriding of adjusted order item

availability:
WCML Version: 4.11.0
description:

Allows overriding of adjusted order item

type:
filter
category:
Orders
parameters:
$language
(string) Order item language to filter
$order
(WC_Order) WC order
hook example usage:

add_filter( ‘wcml_should_save_adjusted_order_item_in_language’, function ( $adjusted_order_item, $item, $language_to_filter ) {
return false;
}, 10, 3 );

Back to the top

wcml_get_order_items_language – Allows overriding which item language to filter.

availability:
WCML Version: 4.11.0
description:

Allows overriding which item language to filter.

type:
filter
category:
Orders
parameters:
$translate
(bool) True if we should save adjusted order item.
$order
(WC_Order) WC order
$language_to_filter
(string) Language to filter
hook example usage:
add_filter( 'wcml_get_order_items_language', function ( $language, $order ) {
	return 'es';
}, 10, 2 );
Back to the top

Shipping

wcml_should_translate_shipping_method_title – Allows overriding the translated shipping method title.

availability:
WCML Version: 4.11.0
description:

Allows overriding the translated shipping method title.

type:
filter
category:
Shipping
parameters:
$should_translate_shipping
(bool) True if we should translate shipping method title.
$title
(string) Shipping title
$shipping_id
(string) Shipping ID
$language
(string) Language
hook example usage:
Back to the top