fbpx
Want To Add Extra Images Per Product Variation For Free? Download Now

Variation switcher changing product language?

Jacek Kitowski

I found a ‘bug’ in your plug-in. I have it installed on a multilingual site with WMPL. I also have PHP code in functions.php that modifies the price depending on the language (the code adds an extra prefix to the price). Everything works fine except for one situation:

  1. we are logged into admin and the language is selected other than Polish
  2. the shop page (frontend) is viewed in Polish
  3. the option “Enable Swatches: Show swatches on archive / shop page.” in your plugin is selected
  4. we are selecting one of the variants using your plugin on archive / shop page

In this case the price of the variant is displayed as if the page was not in Polish. Your plugin, when calculating the variant price on the loaded page, takes the language from the settings in the admin and not the actual language of the displayed price.

My code running the function depending on the language looks like this:

add_filter('woocommerce_get_price_html', 'w360_special_alter_price_display', 9999, 2);
function w360_special_alter_price_display($price, $product) {
  if (get_locale() == 'pl_PL') {
    return w360_special_price_polish($price, $product);
  } else {
    return w360_special_price_other($price, $product);
  }
}

Your plugin triggers ‘w360_special_price_other’ when calculating the variant price even if the site language is Polish. (if English is set in the admin)

On the single product page, everything works well. After changing the variant, the price is correct regardless of the language in the admin. I think it’s because on the archive page the price is loaded via ajax and on the product page it’s not.

I realise this is an edge case, but perhaps you could change this?

Hakik Zaman

Hi Jacek,

Thanks for reaching out to us.

It is beyond our support scope when you use custom code to modify anything. It is difficult for us to provide support for various snippets our customer applies.

If you are using a plugin to modify the price, I could send it to our development for plugin compatibility.

How many approximate variations do you have with each product?

Thank You