Jump to content

adding hook or editing tpl to set currency


koorosh_kdt

Recommended Posts

 

Hi, all of my product selling is base on USD (default) but the customers paying me on ZWL so every couple minutes currency prices updated. 

but I need to remove choose currency sidebar and set the currency for all customers ZWL or the currency id in my whmcs 3, I couldn't find any solution for that in the community so I opened a thread 

 

so far what I could manage is like this:

/// disabing currency selection  *********** its working no problem

add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar) {

   $secondarySidebar->removeChild('Choose Currency');

});

 

///   changing the currency ***********  its not working right :((( 

function hook_change_cart_currency($vars) {

 

   $currentcurrency = $vars['currency'];

  if ($currentcurrency['code'] != "ZWL" OR $_GET["currency"] != "3") {

 if ( $_GET["currency"] != "6") {

    if (App::getCurrentFilename() == 'cart' && $a=='checkout') {

         header('Location: cart.php?a=checkout&currency=3');

       exit;

     }

 

can you help with the second part :) thanks

 

Link to comment
Share on other sites

19 hours ago, koorosh_kdt said:

Hi, all of my product selling is base on USD (default) but the customers paying me on ZWL so every couple minutes currency prices updated.

but I need to remove choose currency sidebar and set the currency for all customers ZWL or the currency id in my whmcs 3, I couldn't find any solution for that in the community so I opened a thread 

it's probably worth mentioning, in case you are unaware, but existing clients who have already made a purchase CANNOT change their currencies - nor should you do it from the admin area (unless you know what you are doing and aware of the consequences).

in other words, if a client has bought a product in USD, when they next login they will only see USD priced products, not ZWL products... they wouldn't even see the currency sidebar as that is only shown to users that are not logged in.

if you have no clients, or none that have made any purchases, it might just be easier to make ZWL your default currency, with USD as a secondary currency - that should remove the need for any redirection hook.

Link to comment
Share on other sites

no problem, with existing users, all of my users will buy with ZWL but   because i'm buying all my servers and services from Europen and US service providers i must set the base price  base on USD, the economy in this part of the world not so stable you know 🙂 , so I'm trying to not get into trouble with sudden currency price change trouble. 

 

so base price should be on USD and ZWL price get the calculated base on currency exchange rates.

Link to comment
Share on other sites

20 hours ago, koorosh_kdt said:

no problem, with existing users, all of my users will buy with ZWL but   because i'm buying all my servers and services from Europen and US service providers i must set the base price  base on USD, the economy in this part of the world not so stable you know 🙂 , so I'm trying to not get into trouble with sudden currency price change trouble. 

I can imagine how bad it is - it's been on the news in the UK a lot.

20 hours ago, koorosh_kdt said:

so base price should be on USD and ZWL price get the calculated base on currency exchange rates.

I assume you realise that WHMCS can't automatically update the exchange rates for you as ZWL is not on the list that they use...

https://docs.whmcs.com/Currencies#Auto_Updating_Rates

Quote

WHMCS has the built in capability to retrieve and update the base conversion rate values daily for the following currencies:

AUD, BGN, BRL, CAD, CHF, CNY, CZK, DKK, EEK, EUR, GBP, HKD, HRK, HUF, IDR, INR, JPY, KRW, LTL, LVL, MXN, MYR, NOK, NZD, PHP, PLN, RON, RUB, SEK, SGD, THB, TRY, USD & ZAR

... even if you could use the exchange rate auto-updater, it would only run once per day, not every few minutes like you want it to.

you would need to find an alternative currency updater - i'm not aware of an existing addon for WHMCS that does that, so it would have to be custom written by a developer for you.

Link to comment
Share on other sites

21 hours ago, koorosh_kdt said:

yes, I wrote already very simple PHP script, auto-updating prices with cron every 30 mins, but my trouble is auto set the currency for people visiting website.

the fact that you have a default currency setup in WHMCS, but don't want to sell in it to clients is a real pain in the proverbial to resolve - because a badly coded hook (yours wouldn't work for a number of reasons) could cause multiple redirection issues.

two thoughts - one way would be to add a currency to the URLs of all your links to the cart - only needs to be the initial link if you have removed the currency dropdown - that was easier in the earlier versions, but now a lot of the cart links are generated in the navbar and you'd need to use a hook to change them.

possibly better solution might be to use the Geolocation Hook For WHMCS free addon as that will have an option to set a default currency for all users; also, there is the Auto Currency addon that will do a similar thing but isn't free.

as there are commercial / free solutions to this situation, there's no real point in me reinventing the wheel and writing something similar. thanks.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated