Skip Navigation

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 5 replies, has 2 voices.

Last updated by ahmedE-13 1 year, 9 months ago.

Assisted by: Mihai Apetrei.

Author Posts
March 3, 2023 at 8:47 pm #13167057

ahmedE-13

I'm trying to add flags to multicurrency but not working, I followed this instruction by WPML but still: https://wpml.org/forums/topic/could-i-add-the-flag-images-in-currency-switcher-with-woocommerce-multilingual-2/#post-2689818

What I did:
-------------

- I have three currencies (OMR, SAR, AED) and the code is the same for each one.
- I have added three png images under my wp-content/uploads/ and named each image as follows (currency-%aed%.png) and (currency-%sar%.png) and (currency-%omr%.png)

- I used the code:

do_action('wcml_currency_switcher', array('format' => '<img src="<u>hidden link</u>"/>%name% (%symbol%)'));

Do I need to change any URLs? because nothing is working. Any help will be appreciated.

March 4, 2023 at 10:28 pm #13170885

Mihai Apetrei
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+02:00)

Hi there.

That custom code might not work anymore due to the fact that the ticket is very old and WPML got a lot of updates since then.

I will try to ask my colleague at the beginning of the week to find out if there's any existing version that works for this but there's a big chance that it might not be and you might need to hire a developer or a WPML contractor (https://wpml.org/contractors/).

I will leave this ticket assigned to myself and I will get back to you as soon as I have a response.

Kind regards,
Mihai Apetrei

March 8, 2023 at 7:37 am #13195761

Mihai Apetrei
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+02:00)

Hi there.

I'm back.

So, it seems that the issue is in the way you named the images.

The name should be "currency-aed.png" NOT "currency-%aed%.png".

Please let me know how things go and if you still need help.

Mihai

March 8, 2023 at 6:33 pm #13201493

ahmedE-13

Hello Mihai,

Thanks a lot for your help. With some tweaking it works. Now I have another issue which is the images showing in the English website but the URL is incorrect in the Arabic website and showing 404.

Basically this is what's happening:

1. I'm using this code:

do_action('wcml_currency_switcher', array('format' => '(<img src="wp-content/uploads/currency-%code%.png" width="26" height="26"/>) %code%'));

2. In the English website each image will have my website URL without any issues. like below:

English Image URL: mywebsite/wp-content/uploads/currency-%code%.png.

3. In Arabic it's giving me 404 because the image URL is changed by adding the ar like below:

Arabic Image URL: mywebsite/ar/wp-content/uploads/currency-%code%.png.

Can you please help me with this?

Thanks

March 8, 2023 at 6:49 pm #13201535

ahmedE-13

It's working now thanks, I just changed the URL to start with / so the image source should be wp-content/uploads/currency-%code%.png.