Thembi Posted July 6, 2016 Share Posted July 6, 2016 I would like to have the functionality to change currency when a user is logged in or not logged in and i would like it to be displayed in the header.tpl . The functionality is already on domainchecker problem is thye form is submitting to domain checker and i want to remain to the same page ... can someone please help 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 6, 2016 Share Posted July 6, 2016 I would like to have the functionality to change currency when a user is logged in or not logged in and i would like it to be displayed in the header.tpl . it's worth remembering that when a client is logged in, and assuming they have made a previous order with you, they cannot change their currency - the option to do so is removed from the cart and/or domainchecker - clients cannot order in multiple currencies. The functionality is already on domainchecker problem is the form is submitting to domain checker and i want to remain to the same page ... can someone please help are you suggesting that you want to add a currency dropdown to the navbar ? if so, you'd need to use an action hook to do that... and disable it when a client is logged in. 0 Quote Link to comment Share on other sites More sharing options...
Thembi Posted July 7, 2016 Author Share Posted July 7, 2016 correct brian that`s exacly what i want to do so that my clients can change currency any time. and i want when a currency is selected from the drop down menu the whole site must change its currency to the one selected ... can you help me with that action hook brian? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 7, 2016 Share Posted July 7, 2016 (edited) Hi, correct brian that`s exacly what i want to do so that my clients can change currency any time. and i want when a currency is selected from the drop down menu the whole site must change its currency to the one selected ... for the avoidance of any confusion with this, I should probably expand on the first sentence of my previous reply. visitors to your website, who are NOT existing clients (e.g they haven't registered or have previous orders with you), CAN change their currency to whatever your website allows - that's absolutely fine. however, as soon as they have registered as a client, they CANNOT change their currency - when they're logged into the client area, they will only be able see pricing in THEIR currency... WHMCS is coded to prevent them from changing currency, so they'd be unable to change it - even via a clever hook in the navbar! if the client has registered, but has NOT made any orders with you, then you can change their currency via the admin area - but if they have made orders, then you should NEVER change their currency... if they need to make an order in another currency, they'd need to create a new account. in WHMCS, the currency is assigned to the client, not to orders, invoices etc - e.g., when WHMCS takes an order for a product with a value of $100, it is stored in the database as "100.00" - no currency settings are stored with the order... when it generates the invoice/emails etc, it uses that stored order value and wraps the client's currency settings around it (i.e adds $ and/or USD)... so if the client has existing orders in USD, and then you later change their currency setting to EUR, the stored order and invoice values would become meaningless (from a financial view) and causes a whole world of pain for you and the client! can you help me with that action hook brian? hopefully, you now understand that existing logged in CLIENTS cannot change their currency - so they wouldn't even see the option... and even if they could see it, it wouldn't work for them anyway. also, where visitors might need to be able to change currency, e.g., cart and domainchecker, there is already an existing method - domainchecker uses flags, cart will either use flags or a dropdown (depending on your template) - so is there any need for a currency changer in the navbar? outside of those pages, i'm not sure the option would be required. however, the above screenshot is taken from an actual hook I quickly wrote (less than 5 mins) to answer your question - it works fine, except if you try to change currency during the middle of the order process - the navbar doesn't know where you are in the process and so returns you to the beginning... perhaps that's why WHMCS never added the currency option to the navbar themselves! Edited July 8, 2016 by brian! 1 Quote Link to comment Share on other sites More sharing options...
Thembi Posted July 8, 2016 Author Share Posted July 8, 2016 Ohw i hear you brian .. for my site visitors to be able to view prices in different currency i think it will be a very nice feature . i want something like this in heaader.tpl {if "not logged in"} then display currency selection {/if} i am advertising some tld`s on my landing page that`s why i think it would be best to have the currency selector only when a client is still a visitor. if you could share your action hook code and how you use it in the heaader.tpl that would be awesome. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 8, 2016 Share Posted July 8, 2016 Hi, i want something like this in heaader.tpl {if "not logged in"} then display currency selection {/if} i am advertising some tld`s on my landing page that`s why i think it would be best to have the currency selector only when a client is still a visitor. if you could share your action hook code and how you use it in the heaader.tpl that would be awesome. hmm... doing it in Smarty in the header template will be easier and better than using a hook - it will correctly change the currency on any page... even half way through the order process. a couple of ideas... I think the most common method would just be to use flags to represent the currencies... in the above image, the selected currency is bold and underlined - for this demo i've used old-fashioned HTML, but you can use CSS to suit your site design... also, i'm not checking if the flag image file exists, so you may want to check that there is a correct flag with a filename that uses the first two letters of the currency code - most major currencies should be there... you would need to add the following code to header.tpl - perhaps after the <!-- Shopping Cart --> block of code... <!-- Currency --> {if !$loggedin && count($currencies) > 1} <div class="pull-right nav"> {foreach from=$currencies item=currchoice} <img src="{$BASE_PATH_IMG}/flags/{$currchoice.code|substr:0:2|strtolower}.png" class="quick-nav"> <a href="{$currentpagelinkback}currency={$currchoice.id}">{if $currency.id eq $currchoice.id}<b><u>{/if}{$currchoice.code}</b></u></a> {/foreach} </div> {/if} if you only have a few currencies, this should be fine - however, if you have a lot of currencies, you may need to find alternate methods of displaying them... one might be to duplicate the way the language options are displayed... to do this, you'd need to add the following code to header.tpl - after the <!-- Language --> block of code... {if !$loggedin && count($currencies) > 1} <div class="pull-right nav"> <a href="#" class="quick-nav" data-toggle="popover" id="currencyChooser"><i class="fa fa-usd"></i> {$LANG.choosecurrency} <span class="caret"></span></a> <div id="currencyChooserContent" class="hidden"> <ul> {foreach from=$currencies item=currchoice} <li><img src="{$BASE_PATH_IMG}/flags/{$currchoice.code|substr:0:2|strtolower}.png"> <a href="{$currentpagelinkback}currency={$currchoice.id}">{if $currency.id eq $currchoice.id}<b><u>{/if}{$currchoice.code}</b></u></a></li> {/foreach} </ul> </div> </div> {/if} additionally, you would need to add some code to six(or custom template)/js/whmcs.js // Currency chooser popover jQuery('#currencyChooser').popover({ container: 'body', placement: 'bottom', template: '<div class="popover language-popover" role="tooltip"><div class="arrow"></div><div class="popover-content"></div></div>', html: true, content: function() { return jQuery("#currencyChooserContent").html(); }, }); ... or perhaps if you wanted a simpler, more elegant, popover... in header.tpl... <!-- Currency --> {if !$loggedin && count($currencies) > 1} <div class="pull-right nav"> <a href="#" class="quick-nav" data-toggle="popover" id="currencyChooser"><i class="fa fa-usd"></i> {$LANG.choosecurrency} <span class="caret"></span></a> <div id="currencyChooserContent" class="hidden"> {foreach from=$currencies item=currchoice} <img src="{$BASE_PATH_IMG}/flags/{$currchoice.code|substr:0:2|strtolower}.png"> <a href="{$currentpagelinkback}currency={$currchoice.id}">{if $currency.id eq $currchoice.id}<u>{/if}{$currchoice.code}</u></a> {/foreach} </div> </div> {/if} and then in whmcs.js... // Currency chooser popover jQuery('#currencyChooser').popover({ container: 'body', placement: 'bottom', template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>', html: true, content: function() { return jQuery("#currencyChooserContent").html(); }, }); hopefully, that's the sort of thing you had in mind! 1 Quote Link to comment Share on other sites More sharing options...
Thembi Posted July 11, 2016 Author Share Posted July 11, 2016 very nice brian... wonderful 0 Quote Link to comment Share on other sites More sharing options...
Tyke Posted July 28, 2016 Share Posted July 28, 2016 Hello Brian, Thanks for the tips so far. This currency selector works fine on the header, but it doesn't work on my custom whmcs website template where I'm using the javascript based data feeds. Any idea how I can display the whmcs products prices on my custom theme without javascript and have this currency selector work for it? Cheers! 0 Quote Link to comment Share on other sites More sharing options...
Tyke Posted July 28, 2016 Share Posted July 28, 2016 Hello Brian, Your tips have been very helpful. Please how can this help to change prices on a whmcs website using the data feeds in a custom template? Cheers... 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 29, 2016 Share Posted July 29, 2016 Please how can this help to change prices on a whmcs website using the data feeds in a custom template? http://docs.whmcs.com/Data_Feeds#Product_Pricing_and_Currency <script language="javascript" src="feeds/productsinfo.php?pid=1&get=price&billingcycle=monthly¤cy=2"></script> 0 Quote Link to comment Share on other sites More sharing options...
Tyke Posted July 30, 2016 Share Posted July 30, 2016 Thanks for the response. I already use this. I have 2 currencies configured, but I wish to have a single currency display at a time, controlled by the currency selector on the page header. 0 Quote Link to comment Share on other sites More sharing options...
Tyke Posted July 30, 2016 Share Posted July 30, 2016 http://docs.whmcs.com/Data_Feeds#Product_Pricing_and_Currency <script language="javascript" src="feeds/productsinfo.php?pid=1&get=price&billingcycle=monthly¤cy=2"></script> Thanks for the response. I already use this. I have 2 currencies configured, but I wish to have a single currency display at a time, controlled by the currency selector on the page header. 0 Quote Link to comment Share on other sites More sharing options...
Tyke Posted July 30, 2016 Share Posted July 30, 2016 Yes, I have used this. but I wish to be able to use one currency at a time (I have two) and allow unregistered users switch the currency displayed on the pages by selecting their currency on the page header. The page header code you wrote it working fine in the cart by the way, but does not work on the the custom whmcs theme using that javascript data feed code. 0 Quote Link to comment Share on other sites More sharing options...
Tyke Posted July 30, 2016 Share Posted July 30, 2016 Yes, I have used this. but I wish to be able to use one currency at a time (I have two) and allow unregistered users switch the currency displayed on the pages by selecting their currency on the page header. The page header code you wrote it working fine in the cart by the way, but does not work on the the custom whmcs theme using that javascript data feed code. 0 Quote Link to comment Share on other sites More sharing options...
Tyke Posted July 30, 2016 Share Posted July 30, 2016 http://docs.whmcs.com/Data_Feeds#Product_Pricing_and_Currency <script language="javascript" src="feeds/productsinfo.php?pid=1&get=price&billingcycle=monthly¤cy=2"></script> Yes, I have used this. but I wish to be able to use one currency at a time (I have two) and allow unregistered users switch the currency displayed on the pages by selecting their currency on the page header. The page header code you wrote it working fine in the cart by the way, but does not work on the the custom whmcs theme using that javascript data feed code. 0 Quote Link to comment Share on other sites More sharing options...
Tyke Posted July 30, 2016 Share Posted July 30, 2016 Yes, I have used this. but I wish to be able to use one currency at a time (I have two) and allow unregistered users switch the currency displayed on the pages by selecting their currency on the page header. The page header code you wrote it working fine in the cart by the way, but does not work on the the custom whmcs theme using that javascript data feed code. 0 Quote Link to comment Share on other sites More sharing options...
Tyke Posted July 31, 2016 Share Posted July 31, 2016 Yes, I have used this. but I wish to be able to use one currency at a time (I have two) and allow unregistered users switch the currency displayed on the pages by selecting their currency on the page header. The page header code you wrote it working fine in the cart by the way, but does not work on the the custom whmcs theme using that javascript data feed code. 0 Quote Link to comment Share on other sites More sharing options...
Tyke Posted August 1, 2016 Share Posted August 1, 2016 Yes, I have used this. but I wish to be able to use one currency at a time (I have two) and allow unregistered users switch the currency displayed on the pages by selecting their currency on the page header. The page header code you wrote it working fine in the cart by the way, but does not work on the the custom whmcs theme using that javascript data feed code. 0 Quote Link to comment Share on other sites More sharing options...
Tyke Posted August 6, 2016 Share Posted August 6, 2016 Yes, I have used this. but I wish to be able to use one currency at a time (I have two) and allow unregistered users switch the currency displayed on the pages by selecting their currency on the page header. The page header code you wrote it working fine in the cart by the way, but does not work on the the custom whmcs theme using that javascript data feed code. 0 Quote Link to comment Share on other sites More sharing options...
Tyke Posted August 8, 2016 Share Posted August 8, 2016 Yes, I have used this. but I wish to be able to use one currency at a time (I have two) and allow unregistered users switch the currency displayed on the pages by selecting their currency on the page header. The page header code you wrote it working fine in the cart by the way, but does not work on the the custom whmcs theme using that javascript data feed code. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 18, 2016 Share Posted August 18, 2016 Thanks for the response. I already use this. I have 2 currencies configured, but I wish to have a single currency display at a time, controlled by the currency selector on the page header. then you'd have to modify the feeds to use the current selected currency instead of specifying the currency in the link. 0 Quote Link to comment Share on other sites More sharing options...
Tyke Posted August 25, 2016 Share Posted August 25, 2016 then you'd have to modify the feeds to use the current selected currency instead of specifying the currency in the link. Thanks Brian for the response. The forum had been messing with my replies all month long. I have no idea how to do this. Is there some tutorial you could point me to, please? Cheers! 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 29, 2017 Share Posted June 29, 2017 update on how to do this in v7.2.2... https://community.whmcs.com/showthread.php?130799-Currency-Selector-on-header-tpl&p=522306#post522306 Update: how to use it without the need for changes to .js files (v6.22 -> v7.5.1 +)... 0 Quote Link to comment Share on other sites More sharing options...
InspireNetHost Posted January 18, 2021 Share Posted January 18, 2021 (edited) On 7/8/2016 at 11:47 AM, brian! said: in header.tpl... <!-- Currency --> {if !$loggedin && count($currencies) > 1} <div class="pull-right nav"> <a href="#" class="quick-nav" data-toggle="popover" id="currencyChooser"><i class="fa fa-usd"></i> {$LANG.choosecurrency} <span class="caret"></span></a> <div id="currencyChooserContent" class="hidden"> {foreach from=$currencies item=currchoice} <img src="{$BASE_PATH_IMG}/flags/{$currchoice.code|substr:0:2|strtolower}.png"> <a href="{$currentpagelinkback}currency={$currchoice.id}">{if $currency.id eq $currchoice.id}<u>{/if}{$currchoice.code}</u></a> {/foreach} </div> </div> {/if} and then in whmcs.js... // Currency chooser popover jQuery('#currencyChooser').popover({ container: 'body', placement: 'bottom', template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>', html: true, content: function() { return jQuery("#currencyChooserContent").html(); }, }); hopefully, that's the sort of thing you had in mind! I was hoping to use this option as I am using v8.1.0 but trying this doesn't get this to display correctly is doesn't also update the prices on the pages to are there any new updates on this to be implemented please? Edited January 18, 2021 by srwilliams86 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 20, 2021 Share Posted January 20, 2021 On 18/01/2021 at 23:38, srwilliams86 said: I was hoping to use this option as I am using v8.1.0 but trying this doesn't get this to display correctly is doesn't also update the prices on the pages to are there any new updates on this to be implemented please? it still works in v8.1... 🙂 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.