Skip Navigation
availability:

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * 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;
}