Nyan Posted January 13, 2017 Share Posted January 13, 2017 I must set JPY and USD in Currencies for SSL Pligin for WHMCS. Please look at Currencies.png. And I must set USD as default currency. But I am dealing only JPY. And I hided USD. When at first my customer register his account, there is no problem. /members/register.php JPY is registered as currency. But when he register from the following URL, there is problem. /members/cart.php?a=checkout USD is registered as currency. I add the following hooks : /members/includes/hooks/currency.php <?php use WHMCS\View\Menu\Item as MenuItem; use Illuminate\Database\Capsule\Manager as Capsule; add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar) { $currencies = Capsule::table('tblcurrencies') ->where('code', '!=', 'USD') ->get(); $content = '<form method="post" action="cart.php?'.$_SERVER["QUERY_STRING"].'"> <select name="currency" onchange="submit()" class="form-control">'; $mycurrency=$_POST['currency']; foreach ($currencies as $currency) { $content .= '<option value="'.$currency->id.'"'; if ($mycurrency==$currency->id) { $content .= ' selected'; } $content .= '>'.$currency->code.'</option>'; } $content .= '</select></form>'; if (!is_null($secondarySidebar->getChild('Choose Currency'))) $secondarySidebar->getChild('Choose Currency') ->setBodyHtml($content); }); I change code as the following : /members/templates/orderforms/standard_cart/sidebar-categories-collapsed.tpl <select name="currency" onchange="submit()" class="form-control"> <option value="">{$LANG.choosecurrency}</option> {foreach from=$currencies item=listcurr} <option value="{$listcurr.id}"{if $listcurr.id == $currency.id} selected{/if}>{$listcurr.code}</option> {/foreach} </select> <select name="currency" onchange="submit()" class="form-control"> {foreach from=$currencies item=listcurr} {if $listcurr.code eq 'JPY'} <option value="{$listcurr.id}"{if $listcurr.id == $currency.id} selected{/if}>{$listcurr.code}</option> {/if} {/foreach} </select> Please tell me how to resolve. Any help would be greatly appreciated!! 0 Quote Link to comment Share on other sites More sharing options...
Nyan Posted January 13, 2017 Author Share Posted January 13, 2017 (edited) I deleted the language files other than Japanese file. But hooks do not worked. USD is registered as currency. Edited January 13, 2017 by Nyan 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 13, 2017 Share Posted January 13, 2017 I deleted the language files other than Japanese file.And hooks worked. JPY is registered as currency. that's weird - the language files shouldn't make any difference to the hooks or template changes. But when I register from mobile, USD is registered as currency./members/cart.php?a=checkout I recognise that code from a previous thread - https://forum.whmcs.com/showthread.php?113791-Hiding-Currency-from-SideBar-Menu-how-to-hide-the-currency is the product priced in both JPY and USD? also, remember when a client has registered and made an order using one currency, they CANNOT change their currency in WHMCS - they will always see pricing in that currency... so if a user has previously bought a product in JPY, when they login at any future point, they will only see JPY pricing not USD. 0 Quote Link to comment Share on other sites More sharing options...
Nyan Posted January 13, 2017 Author Share Posted January 13, 2017 (edited) that's weird - the language files shouldn't make any difference to the hooks or template changes I am sorry. I was wrong. the hooks did not work. I recognise that code from a previous thread - https://forum.whmcs.com/showthread.p...e-the-currency Yes. Thank you. Greatly appreciated! is the product priced in both JPY and USD? Yes. Automatically SSL Pligin sets USD as default currency. Automatically USD price are set. And I set JPY price and change USD price. But customers watch USD by default in my web. I need to show the USD price display to the customer in JPY price display. And I am setting Currencies. Please look at Currencies.png. also, remember when a client has registered and made an order using one currency, they CANNOT change their currency in WHMCS - they will always see pricing in that currency... so if a user has previously bought a product in JPY, when they login at any future point, they will only see JPY pricing not USD. I understand this point. When I register from the following URL, USD is registered as currency. /members/cart.php?a=checkout Edited January 13, 2017 by Nyan 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 13, 2017 Share Posted January 13, 2017 can you PM me a link to your site - I need to get my head around what you're trying to do and what you're seeing. 0 Quote Link to comment Share on other sites More sharing options...
Nyan Posted January 13, 2017 Author Share Posted January 13, 2017 (edited) Yes. Thank you. Greatly appreciated! https://www.bestssl.net/ When I register from the following URL, USD is registered as currency. https://www.bestssl.net/members2/cart.php?a=checkout Edited January 13, 2017 by Nyan 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 13, 2017 Share Posted January 13, 2017 Hi, the only currency option I can see is JPY when I go from the main URL or the cart checkout URL... there is no mention of USD. if you're seeing USD as an option then possibly... a) you are logged in as an existing client who has previously purchased using USD.. b) you need to clear your template cache... utilities -> system -> system cleanup -> empty template cache. 0 Quote Link to comment Share on other sites More sharing options...
Nyan Posted January 13, 2017 Author Share Posted January 13, 2017 Thank you. a) you are logged in as an existing client who has previously purchased using USD.. No. I register as new user from the following URL. https://www.bestssl.net/members2/cart.php?a=checkout b) you need to clear your template cache... utilities -> system -> system cleanup -> empty template cache. I cleared my template cache. I Deleted Suffix of USD. Please look at Currencies_2.png. Please look at cart.png. This is USD price that I Deleted Suffix. Please look at Client_Profile.png. USD is registered as currency. Any help would be greatly appreciated!! 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 13, 2017 Share Posted January 13, 2017 ok, I think i'm starting to see what you're trying to do here. the products are priced in both USD and JPY; USD is your default currency, but you only want to show pricing in JPY - correct? if so, you don't really need any of those hook or template changes above - all they do is prevent the user from switching the site to use USD, but the site is already using USD because it's setup as the default currency... and because there is only one option in the dropdown, they can't even use it to change to JPY... at some point, you should probably remove all of the methods by which they can change currency. WHMCS will always show the pricing in the default currency (in your case, USD) unless a) the user is registered and assigned to another currency - they need not have made an order (if they have made an order, you cannot change their currency; if they have not made an order, you can). b) you specify to use another currency in your links. the simplest solution would be b) to add ¤cy=4 to your links; for example, on your Comodo Positive SSL button... the link currently goes to the default USD price -> https://www.bestssl.net/members2/cart.php?a=add&pid=502 if you add the currency code to the link, it will go to the JPY price -> https://www.bestssl.net/members2/cart.php?a=add&pid=502¤cy=4 once you've passed a currency in a link like that, it will be used for all products - unless another link is used to change it to another currency... but if you remove all the currency change options (sidebar, mobile menu etc), the user will be unable to do that. there is still going to be an issue if someone goes to cart.php?a=checkout etc without specifying a currency, but I think that can be fixed with a hook, e.g if cart currency is not "JPY", then redirect to cart.php?currency=4 0 Quote Link to comment Share on other sites More sharing options...
Nyan Posted January 14, 2017 Author Share Posted January 14, 2017 Thank you brian! greatly appreciated!! the products are priced in both USD and JPY; USD is your default currency, but you only want to show pricing in JPY - correct? It is correct. the simplest solution would be b) to add ¤cy=4 to your links; for example, on your Comodo Positive SSL button... I can resolve my ploblem by adding ¤cy=4. there is still going to be an issue if someone goes to cart.php?a=checkout etc without specifying a currency, but I think that can be fixed with a hook, e.g if cart currency is not "JPY", then redirect to cart.php?currency=4 Redirecting as follows: Is it correct? from:https://www.bestssl.net/members2/cart.php?a=confproduct&i=1 to:https://www.bestssl.net/members2/cart.php?a=confproduct&i=1¤cy=4 from:https://www.bestssl.net/members2/cart.php?a=view to:https://www.bestssl.net/members2/cart.php?a=view¤cy=4 from:https://www.bestssl.net/members2/cart.php?a=checkout to:https://www.bestssl.net/members2/cart.php?a=checkout¤cy=4 I wrote hook. Is this wrong? <?php add_hook("ClientAreaPageCart",1,function($vars){ $currencies = Capsule::table('tblcurrencies') ->where('code', '!=', 'JPY') ->get(); header("Location: cart.php¤cy=4"); exit; }); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 14, 2017 Share Posted January 14, 2017 I wrote hook.Is this wrong? it's close, but ideally you don't need to query the database for this, you need to find out the currency being used in the cart and then change it if it's the wrong one... I quickly wrote the hook below yesterday, which isn't perfect, but should work on your site... <?php function hook_change_cart_currency($vars) { $currentcurrency = $vars['currency']; if ($currentcurrency['code'] != "JPY" OR $_GET["currency"] != "4") { header('Location: cart.php?currency=4'); exit; } } add_hook("ClientAreaPageCart", 1, "hook_change_cart_currency"); ?> 0 Quote Link to comment Share on other sites More sharing options...
Nyan Posted January 14, 2017 Author Share Posted January 14, 2017 Thank you brian! greatly appreciated!! This hook did not work. Correctly: from:/cart.php?a=confproduct&i=1¤cy=1 to: /cart.php?a=confproduct&i=1¤cy=4 But Actually: from:/cart.php?a=confproduct&i=1¤cy=1 to: /cart.php?currency=4 https://www.bestssl.net/members2/cart.php?a=confproduct&i=1¤cy=1 https://www.bestssl.net/members2/cart.php?a=confproduct&i=1¤cy=4 https://www.bestssl.net/members2/cart.php?currency=4 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 14, 2017 Share Posted January 14, 2017 Thank you brian! greatly appreciated!! This hook did not work. remember when I said it wasn't perfect. it does work, but it's not a complete solution - you really only have 2 problems... 1. direct links from your bestssl.net site - but you've solved that by adding ¤cy=4 to the links. 2. anyone visiting your cart main page directly will be solved by the hook redirecting them to the JPY pricing... from there, they can choose the product. however, what it currently can't do is handle links such as your examples (e.g to specific products) - it would need to check the current URL to see if there is a currency in it, if so, remove/change it and then redirect back to the same page.., I thought the above hook should be all you need. 0 Quote Link to comment Share on other sites More sharing options...
Nyan Posted January 15, 2017 Author Share Posted January 15, 2017 I want to limit redirect of cart.php?a=checkout. Is this hook wrong? <?php function hook_change_cart_currency($vars) { $currentcurrency = $vars['currency']; if ($currentcurrency['code'] != "JPY" OR $_GET["currency"] != "4") { if (App::getCurrentFilename() == 'cart' && $a=='checkout') { header('Location: cart.php?a=checkout¤cy=4'); exit; } } } add_hook("ClientAreaPageCart", 1, "hook_change_cart_currency"); ?> 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 15, 2017 Share Posted January 15, 2017 which SSL addon are you using ? 0 Quote Link to comment Share on other sites More sharing options...
Nyan Posted January 17, 2017 Author Share Posted January 17, 2017 I will send Send SSL addon by Private Message. 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.