snake Posted May 11, 2020 Share Posted May 11, 2020 I have USD enabled, since this is required for the marketplace addons. But I do not want customers to be able to pay in USD, I only want them to pay in GBP, otherwise it makes my accounts a nightmare. Is there any easy way to disable all the currency selectors that appear on the all the various pages, I asked WHMCS support, but they said I have to modify all the cart and order form templates, which is going to cause another nightmare, as I will then have to reapply all those changes every time I update WHMCS.. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 12, 2020 Share Posted May 12, 2020 11 hours ago, snake said: I have USD enabled, since this is required for the marketplace addons. MarketConnect... if I had a £1 for every time you say marketplace... 🤑 11 hours ago, snake said: Is there any easy way to disable all the currency selectors that appear on the all the various pages, depends where they are and what's making them... the obvious one would be the "Choose Currency" sidebar that is shown to non-clients in the cart - but you can easily kill that will a hook. <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar) { if (!is_null($secondarySidebar->getChild('Choose Currency'))) { $secondarySidebar->removeChild('Choose Currency'); } }); beyond that, i'm struggling to think of any other default ones.... there would be one in the Modern template if you're still using that... you'd have to remind me of any others.... the other issue would be that the user could just add currency=x into the cart URL and that can be used to switch currencies - though there are ways to prevent that. 13 hours ago, snake said: I asked WHMCS support, but they said I have to modify all the cart and order form templates, almost certainly, that is just utter nonsense - their only get-out would be if they've seen your site and said that... and even then, i'd still be happy to question that assertion. the simplest hook that i've ever seen to force currency in the cart was posted here years ago... <?php if($_SESSION['currency'] != '1') { $_SESSION['currency'] = '1'; } ... put that in the hooks folder, and any non logged in user can't change their currency from whatever 1 is (it should be your default currency) - even if the currency selectors are there or by adding currency=x in the URL... i've written long convoluted hooks to do the same thing that simply aren't as effective as the above hook. 🙂 13 hours ago, snake said: which is going to cause another nightmare, as I will then have to reapply all those changes every time I update WHMCS.. even if you made no changes to the site, I suspect the above hook would force the currency to whatever you want it to be regardless of orderform template... if so, then the rest are just cosmetic changes - if you're lucky, that's hooks and/or css; if you're unlucky, template changes might be required. 0 Quote Link to comment Share on other sites More sharing options...
snake Posted May 12, 2020 Author Share Posted May 12, 2020 LOL yes I know I keep typing marketplace, I can't seem to get out of that habit, sorry if its annoying you 🙂 I did already apply the hook to remove the sidebar selector. It also appears on the checkout and on the marketconnect product pages. so do I just create hook with this code and nothing else? <?php if($_SESSION['currency'] != '1') { $_SESSION['currency'] = '1'; } 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 13, 2020 Share Posted May 13, 2020 12 hours ago, snake said: LOL yes I know I keep typing marketplace, I can't seem to get out of that habit, sorry if its annoying you 🙂 i've got used to it now - if you start calling it MarketConnect, i'd worry that you were unwell or your account had been hacked. 😲 12 hours ago, snake said: I did already apply the hook to remove the sidebar selector. It also appears on the checkout I would have to see a screenshot of the checkout to see where/how the currency option was appearing... 12 hours ago, snake said: and on the marketconnect product pages. see - you can do it if you try. ✔️ 12 hours ago, snake said: so do I just create hook with this code and nothing else? yep - that's it.. it didn't get trimmed in posting, there's no hook point used - what you see is all there is. with that hook active, the currency selectors in the MC pages just reload back to the default currency (for me, that's GBP - if your default is USD, then just use the currency id for GBP)... so if a user chooses USD from the selector, it still loads GBP pricing; chooses EUR and it loads GBP etc.. the user is going to be paying in GBP (unless they're logged in and previously ordered using another currency - in those circumstances, they will continue to use that other currency). as I said yesterday, everything that you need to do from that point on is cosmetic - so it's removing the MC dropdowns.... and i'm tempted to think that the simplest way to do that is to null the currencies array... <?php function remove_currencies_hook($vars) { return array ("currencies" => NULL); } add_hook("ClientAreaPage", 1, "remove_currencies_hook"); as the MC dropdowns are just looping through that array, nuking it would be the quickest way to remove them... if you start seeing issues, then the hook could be limited to just MC pages, but I don't think there should be any issues. btw - you'll still need to use the sidebar hook... and unless you're using an extraordinarily kinky template, there should be no need to "modify all the cart and order form templates" as suggested by Support. 0 Quote Link to comment Share on other sites More sharing options...
snake Posted May 14, 2020 Author Share Posted May 14, 2020 Thanks as always brian. 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.