Skip Navigation
availability:

WooCommerce Multilingual 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;

}