This thread is resolved. Here is a description of the problem and solution.

Problem: Custom Currency Switcher stopped working after update from 4.2.1 to 4.2.3

Solution: Changing the switcher slug to the correct one solve the issue.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Please make sure to update to WPML to the latest and check our list of Known Issues before reporting

This topic contains 11 replies, has 2 voices.

Last updated by Iggy 2 years, 6 months ago.

Assigned support staff: Shekhar Bhandari.

Author Posts
September 12, 2017 at 2:52 pm #1368943

Iggy

After updating from 4.2.1 to 4.2.3 my custom currency switcher stopped working.
It was working well with version 4.2.1

No errors are shown with debug true.
I've updated plugins one by one, and I can confirm that only after updating WooCommerce Multilingual the switcher is not shown anymore. Updated all plugins one by one and only after WooCommerce Multilingual upgrade the switcher disappeared.

Link to a page where the issue can be seen: hidden link

I'll revert to previous version of WooCommerce Multilingual. So please investigate this custom switchers issue on your server.

p.s. I've cleaned wpml cache etc, but no changes. Switcher not showing.

Thanks.

September 12, 2017 at 9:48 pm #1369367

Iggy

no support here??

September 13, 2017 at 6:37 am #1369550

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hi @iggyp,

Thank you for contacting WPML support. I'd be happy to help you on this.

Sorry for the late reply! To debug this issue further I would like to know how you have created the custom currency switcher? Could you please provide the code that you are using to create the custom switcher or steps? So I can test this issue on my local server and provide you feedback.

At the moment, I also request you to try once with the default currency, does this works?

Look forward to your reply.

Thanks

September 13, 2017 at 12:23 pm #1370223

Iggy

Hi!

Custom switcher made according to this article:

https://wpml.org/documentation/related-projects/woocommerce-multilingual/designing-custom-currency-switchers-using-template-files/

On the site you can see it working with previous version 4.2.1
All other wordpress plugins are already latest versions.

config.json:

{
"name": "Iggy Switcher"
}

template.twig:

<div class="{{ css_classes }} currency list-dropdown" >
    <span class="current">{{ selected_currency }} <span class="caret"></span></span>
	<ul>
        {% for currency in currencies %}
            <li>
                <a href="#" rel="{{ currency }}" class="woocs_flag_view_item {% if( currency == selected_currency) %}wcml-cs-active-currency woocs_flag_view_item_current" {% endif %}  data-currency="{{ get_formatted_price( currency, format )|raw }}">{{ get_formatted_price( currency, format )|raw }}</a>
            </li>
        {% endfor %}
    </ul>
</div>

Calling from functions.php to replace default theme switcher (made with some bad plugin)

if ( ! function_exists( 'sober_currency_switcher' ) ) :

	 function sober_currency_switcher() {
		
		// native wpml currency switcher 
		do_action('wcml_currency_switcher', array('format' => '%symbol% %code%', 'switcher_style' => 'sober-child-iggy-switcher') );
		 
	};
endif; 

Please advise.
Thanks.

September 13, 2017 at 3:34 pm #1370552

Iggy

Another bit of info: with older version I need to add another widget to make my custom switcher work. I need to switch predefined widget to my custom design. Then my custom switcher shows too with my design. Very strange... Looks like my custom style not registering unless i add another widget to make it registered.

September 14, 2017 at 5:03 pm #1372305

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello @iggyp,

I tested the issue on my test server and I can't replicate the issue at all as the language switcher is working perfectly for me.

Also, this step wasn't needed at all.

Calling from functions.php to replace default theme switcher

So, could you please try removing this function once and let me know if this helps.

Also, once you made some changes to twig templates make sure to disable enable WooCommerce Multilingual and see if that helps.

Look forward to your reply.

Thanks

September 14, 2017 at 5:18 pm #1372336

Iggy

HI!

Functions.php is replacing default theme switcher (not wpml switcher) added by theme authors. So it is needed. Otherwise it will not show for sure.

Don't making changes to twig template, it's perfect already 🙂 But if I'll upgrade plugin switcher will disappear again 🙁

What do we do now? Can I send you a duplicator file for the site?

Thanks.

September 14, 2017 at 5:20 pm #1372337

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Sure, send me the duplicator package. I need to request temporary access (wp-admin and FTP) to your site in order to be of better help. You will find the needed fields for this below the comment area when you log in to leave your next reply. hidden link

This info is private and available to you and supporters only. Read more about this: https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/

Note that:

#1
Backup (both files and database) your site before giving us your credentials. You can use a plugin for this if you like. I often use the Duplicator plugin for this purpose.
See: http://wordpress.org/plugins/duplicator/

Duplicator instruction
hidden link

#2
It would be better if you give me the test site rather than the live site.

#3
If the issues needs some changes in the plugins updates/disabling we will install a plugin called “duplicator” and replicate the site in our local server for testing.

Look forward to your reply.

Thanks

September 15, 2017 at 10:28 am #1373148

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hi there,

I am little confused here, I can see the switcher working perfectly here: hidden link so could you please check once again if it's working and provide me further steps to replicate the issue.

Look forward to your reply.

Thanks

September 15, 2017 at 11:43 am #1373263

Iggy

Hi! I've told you earlier in the ticket, that I'll revert to previous version. 4.2.1 works. If I update to latest it will not show. Please use duplicator file to test it after update.

September 18, 2017 at 9:09 am #1374859

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hi there,

In functions.php please replace the current code with the following and let me know if this helps. I tested this and it's working for me

if ( ! function_exists( 'sober_currency_switcher' ) ) :

	 function sober_currency_switcher() {
		
		// native wpml currency switcher 
		do_action('wcml_currency_switcher', array('format' => '%name% (%symbol%) - %code%', 'switcher_style' => 'sober-child-theme-iggy-switcher') );
		 
	};
endif; 

Look forward to your reply.

Thanks

September 18, 2017 at 11:19 am #1375040

Iggy

Great, it works now 🙂 So the problem was with theme slug... Please update your documentation.