Forcing Currency by Customer
Posted: Wed Sep 27, 2023 8:27 am
I was hoping to get a bit of assistance nutting out a problem I have.
I run a wholesale business that sells products around the world. We have decided to charge customers from our main countries/regions a static price in THEIR OWN currency. I have been able to assign customers different groups based on region using @raiwa 's Wholesale Pro Addon.
Playing around with the file includes/system/versioned/1.0.8.6/currencies.php I have commented out the sections that multipes the price by the currency exchange value.
Now I need to change the currency based on the group that the customer is in. I am assuming that I need to do this in this function;
First, am i correct that this function controlls the currency for the entire site (at this stage I am just intested in changing the layout of the currency/price with correct symbol ($, £, € etc) due to the changes I mentioned above) ?
Second, I need some help figuring out how to modify it to do what I want;
In simple terms,
I GET the cusomers Group from their record in 'customers' on the database
From there I create a variable who's value will be the same as one of the 'code' values in the currencies table.... EG (USD, AUD, GBP, EUR) I will call this variable 'customer-group'
I can do all that....
What I am stuck with is how to compare the 'customer-group' Value with the 'currencies->code' value and force the currency to reflect the correct currency.
third Where do I save the modified file so I am not changing the core code?
I hope I am not asking too much here, any help will be appreciated even if it's just letting me know if I'm on the right track.
I run a wholesale business that sells products around the world. We have decided to charge customers from our main countries/regions a static price in THEIR OWN currency. I have been able to assign customers different groups based on region using @raiwa 's Wholesale Pro Addon.
Playing around with the file includes/system/versioned/1.0.8.6/currencies.php I have commented out the sections that multipes the price by the currency exchange value.
Now I need to change the currency based on the group that the customer is in. I am assuming that I need to do this in this function;
Code: Select all
public function set_currency() {
if (!isset($_SESSION['currency']) || isset($_GET['currency']) || ( (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') && (LANGUAGE_CURRENCY != $_SESSION['currency']) ) ) {
if (isset($_GET['currency']) && $GLOBALS['currencies']->is_set($_GET['currency'])) {
$_SESSION['currency'] = $_GET['currency'];
} else {
$_SESSION['currency'] = ((USE_DEFAULT_LANGUAGE_CURRENCY == 'true') && $GLOBALS['currencies']->is_set(LANGUAGE_CURRENCY)) ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY;
}
$GLOBALS['currency'] =& $_SESSION['currency'];
}
}First, am i correct that this function controlls the currency for the entire site (at this stage I am just intested in changing the layout of the currency/price with correct symbol ($, £, € etc) due to the changes I mentioned above) ?
Second, I need some help figuring out how to modify it to do what I want;
In simple terms,
I GET the cusomers Group from their record in 'customers' on the database
From there I create a variable who's value will be the same as one of the 'code' values in the currencies table.... EG (USD, AUD, GBP, EUR) I will call this variable 'customer-group'
I can do all that....
What I am stuck with is how to compare the 'customer-group' Value with the 'currencies->code' value and force the currency to reflect the correct currency.
third Where do I save the modified file so I am not changing the core code?
I hope I am not asking too much here, any help will be appreciated even if it's just letting me know if I'm on the right track.