currency switcher

chris37

Well-Known Member
https://snipboard.io/nYlCIv.jpg
https://snipboard.io/qtnQ0W.jpg
i was able to add the flag with this link here https://aelia.freshdesk.com/support...lags-in-the-dropdown-currency-selector-widget

but is have many limitation on my mobile menu ... and also the css is not really working on it.

when i try the css of the flag is conflict with the css of the size of the currency ... i will disable it for now.

@Mar @Direct Webstore i will sent PM you my snippet maybe you can find a way to make it work for all of our site...
 
Last edited:

Mar

Moderator
https://snipboard.io/nYlCIv.jpg
https://snipboard.io/qtnQ0W.jpg
i was able to add the flag with this link here https://aelia.freshdesk.com/support...lags-in-the-dropdown-currency-selector-widget

but is have many limitation on my mobile menu ... and also the css is not really working on it.

when i try the css of the flag is conflict with the css of the size of the currency ... i will disable it for now.

@Mar @Direct Webstore i will sent PM you my snippet maybe you can find a way to make it work for all of our site...
Thanks for that.
 

Mar

Moderator
but is have many limitation on my mobile menu ... and also the css is not really working on it.
For CSS codes for mobile, try this:

@media all and (min-width:321px) and (max-width: 480px) {
/* put your css styles in here */
}

Replace the /* put your css styles in here */ with your codes. It worked for me when I hide elements in mobile but not in PC.
 

chris37

Well-Known Member
For CSS codes for mobile, try this:

@media all and (min-width:321px) and (max-width: 480px) {
/* put your css styles in here */
}

Replace the /* put your css styles in here */ with your codes. It worked for me when I hide elements in mobile but not in PC.
thank i give a try
 

Direct Webstore

Well-Known Member
Last edited:

Direct Webstore

Well-Known Member
EDIT: The CSS code below has been updated.

find a way to make it work for all of our site...
That's not easy as everyone has different themes.

the css is not really working on it.
That CSS code they provided is pretty useless. It's just for the flag image. You don't need it. Just try 24x24 flag images.

I used this ...

select,.select2-container .select2-choice, .select2-container .select2-selection {
background-color: #f7f7f7;
border-radius: 18px;
width: 90px;
}
.select2-container--default .select2-results>.select2-results__options {
max-height: 100%;
}


... with 24x24 flag images.

1. width: 100% would not work. Even with !important
2. Delete the border radius if you don't want rounded corners

3. Change/delete the background-color

This is the best I can get it to look in Flatsome theme. No idea what it would be like in Davinci-Woo.

It looks identical in mobile too. I'm happy with it. Thanks for the newer article!


curr.jpg



And open ...



curr_002.jpg

EDIT: This has been updated on page 8. https://forum.alidropship.com/threads/currency-switcher.16460/post-77762
 
Last edited:
  • Like
Reactions: Mar

chris37

Well-Known Member
That's not easy as everyone has different themes.


That CSS code they provided is pretty useless. It's just for the flag image. You don't need it. Just try 24x24 flag images.

I used this ...

select,.select2-container .select2-choice, .select2-container .select2-selection {
background-color: #f7f7f7;
border-radius: 18px;
width: 90px;
}


... with 24x24 flag images.

1. width: 100% would not work. Even with !important
2. Delete the border radius if you don't want rounded corners

3. Change/delete the background-color

This is the best I can get it to look in Flatsome theme. No idea what it would be like in Davinci-Woo.

It looks identical in mobile too. I'm happy with it. Thanks for the newer article!


View attachment 12924



And open ...



View attachment 12925
Thank i will try later your css code and twisted in my need .
 

Mar

Moderator
That article was posted about 1 month after the almost identical article I posted a link to. I wish they'd delete the outdated ones
I will install Aelia Currency in my other site soon when I have time. So the new codes to install flags are working, or is it the same codes we tried earlier? How about the codes to create a widget area, that is what we don't have earlier, is it necessary? What I am curious now is the difference in loading speed of different currency switchers.
 

Direct Webstore

Well-Known Member
So the new codes to install flags are working,
Yes. The new ones work. I just put them in the "Code Snippets" plugin.

And used this CSS ...

select,.select2-container .select2-choice, .select2-container .select2-selection {
background-color: #f7f7f7;
border-radius: 18px;
width: 90px;
}

Maybe you can improve it.


How about the codes to create a widget area,
I think he pasted them by mistake. I don't know what it's for.
 
  • Like
Reactions: Mar

Direct Webstore

Well-Known Member
This is the working code ... Edit the red part.

I use an "images" folder in my root directory (Wordfence has it covered) for some icons etc so I stuck a "flags" folder there too. Less hassle than using the Media Library and copy/pasting long URLS. Just /images/flags/flag.png is easier to add.


/**
* Runs a JavaScript to add flags to the currency options in the dropdown
* currency selector provided by the Aelia Currency Switcher.
*/
add_action('wp_footer', function() {
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
/**
* Adds flags to the options in the dropdown currency selector.
*/
function add_flag_to_currency_option(currency) {
if(!currency.id) {
return currency.text;
}
var flag_urls = {
// Update this list, adding the URL of each flag
'USD': '/images/flags/united-states.png',
'AUD': '/images/flags/australia.png',
'NZD': '/images/flags/new-zealand.png',
'EUR': '/images/flags/euro.png',
'GBP': '/images/flags/united-kingdom.png',
'CAD': '/images/flags/canada.png',
'SGD': '/images/flags/singapore.png',
'INR': '/images/flags/india.png'
}
var currency_code = currency.id;
if(flag_urls[currency_code]) {
var $currency_option = $(
'<span><img src="' + flag_urls[currency_code] + '" class="aelia-img-flag" /> ' + currency.text + '</span>'
);
}

//console.log(currency);
return $currency_option;
}

// Apply the images to the currency options
$('.widget_wc_aelia_currencyswitcher_widget select').select2({
templateResult: add_flag_to_currency_option,
templateSelection: add_flag_to_currency_option
});
});
</script>
<?php
});

/**
* Loads the Select2 library and CSS on the frontend.
*/
add_action('wp_enqueue_scripts', function() {
wp_enqueue_script('select2');
wp_enqueue_style('select2');
});
 
Last edited:
  • Like
Reactions: Mar
Top