Add compatibility to our discount plugin
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page pleaseIf you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.
Quote from webdados on November 22, 2022, 13:02Hi guys,
I'm the author of the "Taxonomy/Term and Role based Discounts for WooCommerce" plugin that you can find here: https://wordpress.org/plugins/taxonomy-discounts-woocommerce/
We're having an issue while both our plugin and your currency switcher plugin are active. We store the original product price on the cart item, on a custom array index of each cart line, and then each time the cart is loaded from the session, we just calculate the discount again to show it on the cart. The problem is that when the currency switches, our base/original price is the same value as the previous currency so each time the user changes the currency and there are items on the cart, the values are changing constantly because calculations are made based on the previous currency and then stored again on our array but as the new currency.
Long story short: it's a mess! We're not expecting the currency to change while there are products on the cart.
Do you have any helper function we can use to convert the values, each time the currency is changed by the user, and make our plugin compatible?
Hi guys,
I'm the author of the"Taxonomy/Term and Role based Discounts for WooCommerce" plugin that you can find here: https://wordpress.org/plugins/taxonomy-discounts-woocommerce/
We're having an issue while both our plugin and your currency switcher plugin are active. We store the original product price on the cart item, on a custom array index of each cart line, and then each time the cart is loaded from the session, we just calculate the discount again to show it on the cart. The problem is that when the currency switches, our base/original price is the same value as the previous currency so each time the user changes the currency and there are items on the cart, the values are changing constantly because calculations are made based on the previous currency and then stored again on our array but as the new currency.
Long story short: it's a mess! We're not expecting the currency to change while there are products on the cart.
Do you have any helper function we can use to convert the values, each time the currency is changed by the user, and make our plugin compatible?
Quote from Pablo Borysenco on November 23, 2022, 11:10Hello
All prices should be stored in the base currency
Before adding to the array, you should do the reverse conversion
if (class_exists('WOOCS')) {
global $WOOCS;
$currency = $WOOCS->current_currency;
$currencies = $WOOCS->get_currencies();
$rate = $currencies[$currency]['rate'];
$Your_price = floatval( $Your_price) / $rate;
}
Hello
All prices should be stored in the base currency
Before adding to the array, you should do the reverse conversion
if (class_exists('WOOCS')) {
global $WOOCS;
$currency = $WOOCS->current_currency;
$currencies = $WOOCS->get_currencies();
$rate = $currencies[$currency]['rate'];
$Your_price = floatval( $Your_price) / $rate;
}
Quote from webdados on November 23, 2022, 13:58Do you run any action when the currency is changed, one that we can hook into and do our stuff?
Looking at the way we're doing things in our plugin, it's more transparent to convert the array on the car each time the currency is changed.
Do you run any action when the currency is changed, one that we can hook into and do our stuff?
Looking at the way we're doing things in our plugin, it's more transparent to convert the array on the car each time the currency is changed.
Quote from Pablo Borysenco on November 24, 2022, 10:22Hello
Please read this - https://currency-switcher.com/codex#actions and https://currency-switcher.com/codex#filters
Conversion Hooks - woocs_raw_woocommerce_price and woocs_woocommerce_variation_prices
Hello
Please read this - https://currency-switcher.com/codex#actions and https://currency-switcher.com/codex#filters
Conversion Hooks - woocs_raw_woocommerce_price and woocs_woocommerce_variation_prices
Quote from webdados on November 24, 2022, 12:48Hi again,
I couldn't find any hook that runs when the currency is changed.
I think this change to the WOOCS->set_currency() method could work for me, or any other developer that wants to do anything when the currency is changed:
Basically, before changing the currency we store the current/previous currency:
$previous_currency = $this->current_currency;
And then at the end run the action:
do_action( 'woocs_currency_changed', $previous_currency, $currency );
Could you implement this, please?
Hi again,
I couldn't find any hook that runs when the currency is changed.
I think this change to the WOOCS->set_currency() method could work for me, or any other developer that wants to do anything when the currency is changed:

Basically, before changing the currency we store the current/previous currency:
$previous_currency = $this->current_currency;
And then at the end run the action:
do_action( 'woocs_currency_changed', $previous_currency, $currency );
Could you implement this, please?
Quote from Pablo Borysenco on November 24, 2022, 13:15It doesn't make any sense. 'woocs_currency_changed' - this will just work on every page load
In fact, the currency switches when the page is reloaded.
so just check the current currency for example in the hook "wp_head"
It doesn't make any sense. 'woocs_currency_changed' - this will just work on every page load
In fact, the currency switches when the page is reloaded.
so just check the current currency for example in the hook"wp_head"
Quote from webdados on November 24, 2022, 13:49OK, I wasn't aware this function runs on every page load.
So there's nowhere in your code, that an action can be created, passing the previous currency and new currency only when it changes?
OK, I wasn't aware this function runs on every page load.
So there's nowhere in your code, that an action can be created, passing the previous currency and new currency only when it changes?
Quote from Pablo Borysenco on November 25, 2022, 10:55Hello
Unfortunately there is no such hook.
Hello
Unfortunately there is no such hook.
