Question about currency setup
-
Hello,
thanks for this useful plugin! I installed the plugin locally and it works fine. However when I use the plugin I need to update all of my products, as I want not to I tried to create the functions needed for changing the currency on product level in my functions.php. However I am a bit puzzled, because of the following:First I commented all the add_filter statements in your core_class. After that the change of the currency was gone. That was okay, then I uncommented
add_filter( 'woocommerce_currency', array( $this, 'change_currency_code' ), PHP_INT_MAX );
And the correct currency for my product is displayed. For the product I am looking at I set it up as “USD”, the usual store currency is CAD.
Why I am puzzled is because of this, I checked the function that is tied to the hook:
function change_currency_code( $currency ) { if ( false != ( $_currency = $this->get_current_product_id_and_currency() ) ) { return $_currency; } elseif ( $this->is_cart_or_checkout() ) { return ( false != ( $_currency = $this->get_cart_checkout_currency() ) ) ? $_currency : $currency; } var_dump($currency); die(); return $currency; }
$currency, was “CAD”, but the product is displayed in USD, which is correct.
When I do copy the necassary functions from your plugin to my functions.php, the result is the same – the filter does return “CAD”. However my code in my functions.php has no effect. So the plugin changes the language to USD, but my code not.
Am I missing something that changes the currency? Within the function which is tied to the hook does not happen that much…
$this->get_current_product_id_and_currency()
this does return false and I am on a single product page…Even when I change my code to this, the price is displayed only as ‘3.409’ – so without a dollar sign. Once I uncomment your hook, it is displayed with the dollar sign:
function filter_woocommerce_currency( $currency ) { if ( false != ( $_currency = get_current_product_id_and_currency() ) ) { return $_currency; } $currency = 'USD'; return $currency; }; add_filter( 'woocommerce_currency', 'filter_woocommerce_currency', PHP_INT_MAX, 1);
It would be great if you can point me in the right direction…
Thanks!
- The topic ‘Question about currency setup’ is closed to new replies.