Responsive popup currency selection

In this tutorial i want to show you how easily you can create currency selection popup window that will appear for your shop guests on their first page visit in your store (no matter what page they will open - popup will appear). This popup will obligue them to select currency. Only in that way they will be able to close modal window. Whole guide is based on our PrestaShop responsive popup pro module. Currency selection will look like on the image below.

 

PrestaShop popup currency selection

 

 

How to create popup with currency selection

As i already mentioned, we have to install PrestaShop popup addon . We will use it to create popup that will appear for:

- everyone who will visit your shop for the first time
- everywhere, no matter what page customer will open - module will spawn this popup

- only one time, module will not spawn popup again
- customer will be obligue to select currency to close the popup

Let's open module configuration page, and go to "add new popup" section. Fill popup creation form with these informations:

Name Currency selection (in fact you can use own, it appears only in back office)
Active Yes
Test mode No
Display popup again after: 36000000
PopUp border 10
PopUp border color EEF5DB
PopUp background (window) EEF5DB
PopUp overlay color (background) 000000
PopUp overlay opacity 0.9
Disable default "close button" YES
Disable "click anywhere" to close YES
Appearance delay 0
Popup width 460
Popup height (leave it blank, popup height will fit to its contents)

The rest of the settings are related to visibility of the popup on selected pages etc. Don't use these options because we want to dispaly popup anywhere - no matter what page customer will open for its first shop page visit. That;s akk ub case related to popup appearance settings. Now it's time for the most important part related to contents of popup window.

 

Currency selection form in popup

To create selection form we must know how many currencies we have in our shop and what is the ID of each currency that we have in our store. To check these informations go to localization > currencies section in your shop back office. You can find out there list of the currencies you have with their id numbers (it's important to know ID!)

 

How to get currency ID in PrestaShop

prestashop currencies how to get id

Screenshot above shows localization > currencies section in PrestaShop 1.6, if you are on PrestaShop 1.7 you need to go to international > localization > currencies section and open currency page, id of currency will be visible in address bar, like on this screenshot

 

Based on these informations we have to create proper currency selection code. For example, if we have 2 currencies: Pound (ID:1), Złoty (ID:2) we have to create code like this:

PrestaShop 1.6.x + PrestaShop 1.7.x

    <li onclick="setCurrency(1); $.closeOverlay();"><a rel="nofollow" title="Pound (GBP)">(GBP)<br />Pound</a></li>
    <li onclick="setCurrency(2); $.closeOverlay();"><a rel="nofollow" title="Złoty (PLN)">(PLN) <br />Złoty</a></li>

Let me explain what the most important part of code mean.

onclick="" Code inside "" will be called right after we will click on currency button
setCurrency(1); here is an ID numer of currency for button. Customer will switch currency to this one after click on button

So as you can see, we have to customize code to meet our shop configuration. We have to change setCurrency() param and currency name in the <li> elements. You can create as much buttons as you want. So - in that way - you can display each currency button.

The full code of the currency selection looks like:

<h2 style="text-align: center;">Select your currency</h2>
<ul class="popupcurrencies">
<li onclick="setCurrency(1); $.closeOverlay();"><a rel="nofollow" title="Pound (GBP)">(GBP)<br />Pound</a></li>
<li onclick="setCurrency(2); $.closeOverlay();"><a rel="nofollow" title="Złoty (PLN)">(PLN) <br />Złoty</a></li>
<li onclick="setCurrency(3); $.closeOverlay();"><a rel="nofollow" title="Euro (EUR)">(EUR) <br />Euro</a></li>
<li onclick="setCurrency(4); $.closeOverlay();"><a rel="nofollow" title="Dollar (USD)">(USD) <br />Dollar</a></li>
</ul>
<style>
.popupcurrencies {
list-style:none;
margin:auto;
display:block;
min-width:450px;
clear:both; overflow:hidden;
}
.popupcurrencies li a {
display:inline-block;
background: #FE5F55;
color:#F0B67F;
font-size:14px;
font-weight:bold;
text-align:center;
padding:20px;
border-radius:4px;
width:100px;
float:left;
margin:5px;
cursor:pointer;
}

.popupcurrencies li a:hover {
background:#FF8077;
}
</style>

 

If you are on PrestaShop 1.7.x

You need to add additional contents to the popup. Paste this javascript code right below the contents of popup. 

<script>
function setCurrency(idc) {
location.href = '?SubmitCurrency=1&id_currency='+idc; 
}  
</script>

 

You just have copy this code and paste it to "desktop view" "mobile view" and "tablet view" textboxes on module configuration page.
don't forget to customize setCurrency() with ID numebrs of your currencies, and don't forget to change currencies names.

 

author milos myszczuk
Article by Milosz Myszczuk PrestaShop expert, official PrestaShop community moderator. PHP developer, specialist in relative and spatial databases management, GIS Analyst, CEO & founder of VEKIA interactive agency. Read more about VEKIA company
If you like my articles and want much more valuable tips, feel free to send me donation
1.4 version 1.4.11 1.6 404 addon admin advertise ahref ajax alpha animation api app application authentication back office backup badge banner basics block bootstrap button cache carrier cart catalog category certificate changelog chat class clear client clip cms code colors columns comments configuration contact container content controller cookie counter country coupon css csv currency customer dashboard database debug default delete delivery desktop developer device disable discount displayNav displayTop download dynamic editor effect empty encrypt engine error exchange exclude export facebook faceshop fade fancoupon fancybox fanpage fatal feature feed field file fix fixed font footer free friendly url front ftp full gallery generate gift global godaddy google google+ gray grid groupon header help hide highlight homefeatured homepage hook hosting hover howto htaccess html html5 ID image import include input instagram installation integration iPhone issue javascript jquery kgb knowhow languages law left likebox link list livingsocial loading log login logo loyality mail mailing maintenance manufacturer marketing marquee mcrypt menu meta mobile modification module movie moving multilanguage multiupload must have mysql news newsletter notification number open graph order override page password performance PHP phpmyadmin picture pinterest plugin popup post prestashop prestashop 1.0 prestashop 1.1 prestashop 1.2 prestashop 1.3 prestashop 1.4 prestashop 1.5 price rules problem product profile promotion proslider purifier quantity query quick tip random rates register reinsurance release reporting reset responsive restore results ribbon rich text right sales search security seo service shadow share shipping shop shopmania slider smarty social networks SQL SSL statistics stock store style subcategory superuser support switcher tab tablet tag tax template text theme tinyMCE tips and tricks tpl tracking translations tree trends trigger tumblr tutorial twitter update upgrade upload variables video visits voucher vulnerability web2print wide widget width window wishlist wysiwyg youtube zip zopim