I'm trying to create a custom currency switcher that also includes the currency name (United States (US) dollar) like displayed in the backend next to the currency code (USD).
And have been able to create my own template, but I can't seem to figure out how I can modify the `currencies` array that's it's looping over in the twig template:
`{% for currency in currencies %}...{% endfor %}`
So I'm trying to use my own function in the loop (just like the get_formatted_price) from my namespaced php class to retrieve the currency name
but it's not recognized in twig.
I can see the `get_formatted_price` function is being registered in the construct of the WCML_Currency_Switcher_Template class.
Is it possible to use my own function in twig or do I need to register it first with `WPML\Core\Twig_SimpleFunction`?
-----------------
Just as a disclaimer, i remind you we can't write code for you so we're a bit restricted on what we can do (I know you didn't ask for it, this is just a general disclaimer)
Thanks, I ended up using my own blade partial with a view composer using those functions you mentioned instead of trying to use twig. All you have to make sure is to add the 'wcml_currency_switcher' class so it will still use the bundled javascript from WPML.
Manage Cookie Consent
We use cookies to optimize our website and services. Your consent allows us to process data such as browsing behavior. Not consenting may affect some features.
Functional
Always active
Required for our website to operate and communicate correctly.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
We use these to analyze the statistics of our site. Collected information is completely anonymous.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
These cookies track your browsing to provide ads relevant to you.