Skip Navigation

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

Problem:
The client is setting up the currency switcher using the [currency_switcher] shortcode in their theme's header but is unable to configure it to display horizontally and show only the currency code instead of a dropdown list.
Solution:
First, we recommend increasing the PHP memory limit to meet WPML's minimum requirements for better performance. You can do this by accessing your server via FTP, opening the wp-config.php file, and inserting the following lines just before the 'That's all, stop editing! Happy blogging.' comment:

/* Memory Limit */
define('WP_MEMORY_ LIMIT', '256M');
define('WP_MAX_MEMORY_LIMIT', '256M');

For more information, visit WPML's minimum requirements.

For customizing the currency switcher to display horizontally and show only the currency code, refer to our documentation here: Multi-Currency Support for WooCommerce. You can use the following PHP code to achieve this:

do_action('wcml_currency_switcher', array(
  'format' => '%code%',
  'switcher_style' => 'wcml-horizontal-list'
));

If this solution does not apply to your case, or if it seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If further assistance is needed, please open a new support ticket.

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.

This topic contains 1 reply, has 2 voices.

Last updated by Nicolas V. 2 years, 6 months ago.

Assisted by: Nicolas V..

Author Posts
June 10, 2022 at 12:56 pm #11434311

razvanB

Hello! I am currently setting up the currency switcher on an improved version of a website I work on. I used the [currency_swithcer] shortcode to place it in my theme's header, but don't know how to set it up to be a horizontal one and show up only the currency code. I tried to set these up in the "show currency switcher in a widget" section, but it doesn't really work, it just deactivates the dropdown and shows them like a vertical list also with all elements not just the code. I don't need it in a widget, anyway, i'm using the shortcode to show it in the menu.

So, any idea on how to customize the switcher show using the shortcode?

PS: Tried to use CSS, but all the elements are in an <a> tag and I can't really eliminate text inside it without forcing it with some extra javascript. You can see in the screenshot it's pretty messed up.

Thnx!
Thanks!

Screenshot 2022-06-10 155225.png
June 11, 2022 at 1:20 pm #11440045

Nicolas V.
Supporter

Languages: English (English ) French (Français )

Timezone: America/Lima (GMT-05:00)

Hello,

Welcome to the WPML support forum. My name is Nicolas and I will be happy to help you today.

Let's start by meeting WPML's minimum requirements. I've noticed your website has a low PHP memory allocation (40M). The minimum requirements for WPML is 128M but we recommend 256M:

Access your server via FTP and open wp-config.php (in your WordPress root directory).

Insert those lines just before /* That's all, stop editing! Happy blogging. */

/* Memory Limit */
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' );

More info: https://wpml.org/home/minimum-requirements/
---

Now regarding the currency switcher shortcode, please refer to our documentation:
https://wpml.org/documentation/related-projects/woocommerce-multilingual/multi-currency-support-woocommerce/#currency-switcher-shortcode

As you can see if you are using a shortcode you can customize the template with the attribute format [currency_switcher format="%code% (%symbol%)"].

But if you want also to change the style for horizontal list, then you will need to use a PHP Code (see the section "Currency Switcher as PHP Code" from the same documentation)
Example:

do_action('wcml_currency_switcher', array(
  'format' => '%code%',
  'switcher_style' => 'wcml-horizontal-list'
));

Cheers,
Nico