PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

You need to log-in to create request (topic) to the support

Need to exclude a specific product category from using GeoIp rules. Help Appreciated.

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 please
If 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.

In general, I want to know how to exclude only a certain product type from displaying prices based on GeoIp rules

My store's main prices are in British pounds (GBP) but if someone from Thailand, visits my shop, woocommerce prices will switch to display in Thai baht (THB).

However, there’s one product category ('auction') in which I always want my prices displayed in GBP regardless of my customer's country.  Although at checkout, they should still be allowed to pay with their own local geo currency.

The code I have above works for the category “auction“ in that it sets the price in GBP even though I’m visiting the website from Thailand (in which case prices should be in THB because of Geo detection).

However, after it sets the price in GBP for a page in this product category (‘auction’), any other page I visit will also have prices displayed in GBP instead of switching back to THB for the usual Geo detection of Thailand.

I hope I’m explaining this clearly. Any idea how to get the changes I’m trying to make stick only to the pages I want?

thanks for any help and advice. 🙏🏽

 

I asked this question on Facebook and someone suggested the following, but I can’t figure out how to implement it:

“Facebook User:

I suspect Woo currency switcher is storing a cookie so that once you have changed the currency, it will stick for that user.

If I am correct, adding an ELSE statement would fix. Move global $WOOCS outside of your IF statement then add:

else {

$customer_country = $this->storage->get_val('woocs_user_country'); //fix this because $this won't have a reference, there will be a function to get the customer country

$currency = $WOOCS->get_currency_by_country($customer_country);

$WOOCS->set_currency($currency);

}”

My latest code that isn’t working looks like this:

add_filter('wp_head', 'set_custom_currency');

function set_custom_currency () {    

    if( has_term( 'auction', 'product_cat' ) ) {

      global $WOOCS;

        $WOOCS->set_currency('GBP');

    } else {

$customer_country = $this->storage->get_val('woocs_user_country'); //fix this because $this won't have a reference, there will be a function to get the customer country

$currency = $WOOCS->get_currency_by_country($customer_country);

$WOOCS->set_currency($currency);

}

}

Hello

Please try this  code:

add_filter('wp_head', 'set_custom_currency');

function set_custom_currency () {    
if (!class_exists("WOOCS")) {
return;
}
global $WOOCS;
    if( has_term( 'auction', 'product_cat' ) ) { 
          $WOOCS->set_currency('GBP');

    } else {

$customer_country = $WOOCS->storage->get_val('woocs_user_country'); //fix this because $this won't have a reference, there will be a function to get the customer country

$currency = $WOOCS->get_currency_by_country($customer_country);

$WOOCS->set_currency($currency);

}

}

Thank You, Pablo.

This code works great.

BTW, is there any chance you could add support for this auction plugin:  https://woocommerce.com/products/auctions-made-easy-for-woocommerce/

I can send you a .zip copy of it if needed.  Thanks

Hello

Please  raed  this - https://currency-switcher.com/woocs-labs

You can drop me  wp-admin+FTP access  to your  test  site - https://share.pluginus.net/image/i20210618130558.png ->https://share.pluginus.net/image/i20210618130637.png

I'll add it to the adaptation queue