我就是这样解决的:
/**
* Force currency change
*/
add_filter( \'wcml_client_currency\', function($current) {
if(isset($_GET[\'currency\']) && $_GET[\'currency\'])
return $_GET[\'currency\'];
if(isset($_POST[\'currency\']) && $_POST[\'currency\'])
return $_POST[\'currency\'];
return $current;
} );
然后,为了监听上述过滤器,您必须添加以下代码:
add_action( \'wp_ajax_quick_view_single_product\', __NAMESPACE__ . \'\\\\quick_view_single_product\' );
add_action( \'wp_ajax_nopriv_quick_view_single_product\', __NAMESPACE__ . \'\\\\quick_view_single_product\' );
function quick_view_single_product() {
wc_get_template(\'modal-single-product.php\');
die();
}
/**
* Ensure WCML\'s currency filters are listened to
*/
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[] = "quick_view_single_product"; // Add a AJAX action to the array.
return $ajax_actions;
}