One of the most conditions that can cause this issue is the generation of a feed "on the fly". A remote server connects to the WooCommerce site, to request the feed, and the currency is set depending on the IP address of the request. Most feed services use bots that connect from the US, and they receive a feed in USD, even though they might expect it in a different currency.
Product feeds are generated by a plugin. If the plugin produces the feed "on the fly" by calling a special URL (e.g. https://example.org?generate_feed=1), one solution could be to enable the "currency by URL" feature in Currency Switcher > Currency Selection (see https://prnt.sc/gpd3vj), then pass the currency via the URL, as https://example.org?generate_feed=1&aelia_cs_currency=GBP. That would change the active currency on the fly, and it should result in a feed generated in that currency.
1.2. Set the feed currency using a filter when the feed URL is called
add_filter('wc_aelia_cs_selected_currency', function($selected_currency) { // If current page URL contains a specific "generate feed" argument, // force the currency to GBP. // In this example <SOME ARGUMENT> and <SOME VALUE> would have to be // replaced by the actual name and value of the argument passed by // Facebook, or Google Merchants, when calling the site to fetch the feed. if(isset($_GET['<SOME ARGUMENT>']) && ($_GET['<SOME ARGUMENT>'] === '<SOME VALUE>')) { // Force selected currency to GBP $selected_currency = 'GBP'; } return $selected_currency; });
Important
1.2.1. Force the active currency for bot visitors
$bot_types
variable would allow to identify the calls from the Facebook bot and set the active currency in that context.- Using the actions and filters provided by the feed plugin, intercept the generation of the feed. The authors of the feed plugin should be able to tell what event should be used.
- Use some custom code to change the active currency to GBP on the fly, as described in the article mentioned earlier (How to change the selected currency via code, example #3), just before the feed data is generated.
/** * Sets the active currency to a specific one * * @param string $selected_currency * @return string */ function aelia_set_feed_currency($selected_currency) { // Set the currency to GBP return 'GBP'; } /** * Overrides the active currency before the generation of a feed. */ add_action('<BEFORE FEED GENERATION STARTS>', function() { add_filter('wc_aelia_cs_selected_currency', 'aelia_set_feed_currency', 99); }); /** * Removes the currency overrides after the generation of a feed. */ add_action('<FEED GENERATION COMPLETE>', function() { remove_filter('wc_aelia_cs_selected_currency', 'aelia_set_feed_currency', 99); });
Important
2. Contact us if you have any questions
As indicated at the top of the article, all the code examples are provided on an "as is" basis, and they fall outside the scope of our support service. Although we won't be able to implement them for you, nor provide a guarantee that they will work, we will be happy to answer any questions you might have. You can simply contact us, and we will get back to you as soon as possible.
You can purchase the Currency Switcher from our online shop.