|
WooCommerce Google Product Feed and Woocommerce Multilingual Multi-currency support
Started by: marcelaB-4
in: English Support
Quick solution available
Problem:
How to create a link for the WooCommerce Google Product Feed plugin to include the multi-currency support for the translated products.
Solution:
Add the following code to the functions.php file of your theme:
add_filter( 'wcml_client_currency', 'modify_client_currency', 10, 1 );
function modify_client_currency( $current_currency ) {
if( !is_admin() ){
global $woocommerce;
$currency = isset( $_GET['currency'] ) ? esc_attr( $_GET['currency'] ) : $current_currency;
$currency = strtoupper( $currency );
$woocommerce->session->set('client_currency', $currency);
return $currency;
}
}
After that, if you use the parameter language URL format add a link like this to the product feed:
website.com/?lang=CODE¤cy=CUR
For the directory mode language URL format:
website.com/CODE/?currency=CUR
Replace CODE with the language code and replace CUR with the currency that you want.
Relevant Documentation:
https://wpml.org/wcml-hook/wcml_client_currency/
|
|
2 |
15 |
2 years, 5 months ago
marcelaB-4
|