Forcing default currency at checkout
I recently upgraded to 1.5.4. Wanting to offer customers the opportunity to see prices in their own currency, I installed the currencies sidebox. However, I need to process transactions in AUD only.
Some customers would select a currency but that selection remained throughout the checkout process and only the invoice total was shown in AUD. This also caused problems with PayPal registering as a currency conflict.
I searched for information on how to force the default currency at checkout and found that people had asked, but never seem to have received a solution. I know that you can stop the currencies sidebox from displaying during checkout, but that doesn't help if the wrong currency is active.
My solution was to modify one file: cart/includes/init_includes/init_currencies.php
I made two insertions. First insertion near the top of the code:
PHP Code:
if (!defined('IS_ADMIN_FLAG'))
{
die('Illegal Access');
}
// begin insertion 1 of 2
$force_default_currency = false;
$requested_page = $_SERVER['REQUEST_URI'];
// Does requested page contain the string 'checkout'?
// If so, then force currency to default
if (strpos($requested_page, 'checkout') !== false)
{
$force_default_currency = true;
}
// end insertion 1
The second insertion is just before the end of the code:
PHP Code:
// begin insertion 2 of 2
elseif ($force_default_currency)
{
$_SESSION['currency'] = DEFAULT_CURRENCY;
// redraw the page without the currency/language info in the URL
if (isset($_GET['currency']) || isset($_GET['language'])) zen_redirect(zen_href_link($current_page_base, zen_get_all_get_params(array('currency','language'))));
// end insertion 2
}
?>
This has solved my issue completely and my method may be helpful to others.
Re: Forcing default currency at checkout
Same can be achieved without a hack.
No matter how many currencies are visible/selectable on the front end, all you need to do in Admin > Modules > Payment > PayPal Express is to set
Transaction Currency
Only AUD
That's it, has worked for me since 2007
Re: Forcing default currency at checkout
That is how my payment module is set.
As I said, it does put the final total in AUD but everything else in checkout is in the selected currency. Also, I cannot complete the transaction (I only authorise transactions at checkout) because PayPal senses a currency conflict. (I can, however, complete the transaction through my PayPal account rather than Zen's admin.)
I didn't have this issue with 1.3.9. I am sure it behaves as you suggest. However, I am happy with my hack.
3 Attachment(s)
Re: Forcing default currency at checkout
I am experiencing the same thing with a fresh install of 1.5.4. Is the hack the only way to fix this? 1.3.9 worked fine.
This is my setup.
PayPal Payments Pro (USA)
Attachment 15991
PayPal Express Checkout via Payflow Pro
Attachment 15992
Here is an order I received today
Attachment 15993
Re: Forcing default currency at checkout
Is the hack the only way to fix this? In the absence of any other suggestions, I am assuming so.
Re: Forcing default currency at checkout
Right on. I'll give that a shot. Thanks!
Re: Forcing default currency at checkout
Quote:
Originally Posted by
haroldf
I recently upgraded to 1.5.4. Wanting to offer customers the opportunity to see prices in their own currency, I installed the currencies sidebox. However, I need to process transactions in AUD only.
Some customers would select a currency but that selection remained throughout the checkout process and only the invoice total was shown in AUD. This also caused problems with PayPal registering as a currency conflict.
I searched for information on how to force the default currency at checkout and found that people had asked, but never seem to have received a solution. I know that you can stop the currencies sidebox from displaying during checkout, but that doesn't help if the wrong currency is active.
My solution was to modify one file: cart/includes/init_includes/init_currencies.php
I made two insertions. First insertion near the top of the code:
PHP Code:
if (!defined('IS_ADMIN_FLAG'))
{
die('Illegal Access');
}
// begin insertion 1 of 2
$force_default_currency = false;
$requested_page = $_SERVER['REQUEST_URI'];
// Does requested page contain the string 'checkout'?
// If so, then force currency to default
if (strpos($requested_page, 'checkout') !== false)
{
$force_default_currency = true;
}
// end insertion 1
The second insertion is just before the end of the code:
PHP Code:
// begin insertion 2 of 2
elseif ($force_default_currency)
{
$_SESSION['currency'] = DEFAULT_CURRENCY;
// redraw the page without the currency/language info in the URL
if (isset($_GET['currency']) || isset($_GET['language'])) zen_redirect(zen_href_link($current_page_base, zen_get_all_get_params(array('currency','language'))));
// end insertion 2
}
?>
This has solved my issue completely and my method may be helpful to others.
Ended up in need of your hack after installing the eWay payment module as my merchant facility only accepts order currency AUD.
Had no further issues after implementation of your code - thanks!
Frank
Re: Forcing default currency at checkout
Hello Frank. Glad that it is helpful.
Re: Forcing default currency at checkout
Since the currency-conversion requirement is something enforced/required by your specific payment module/gateway, I recommend putting code into the payment module itself to handle the conversion during submission. That way the customer still sees the checkout in their own currency and you don't need to interfere with normal currency handling otherwise.
Here's how it's done in the Authorize.net AIM module: https://github.com/zencart/zencart/b....php#L396-L403
Obviously you'll need to adjust the specifics for however your gateway prepares its fields for transmission, but this shows you the basics of the calculation logic.
Re: Forcing default currency at checkout
Quote:
Originally Posted by
DrByte
Since the currency-conversion
requirement is something enforced/required by your specific payment module/gateway, I recommend putting code into the payment module itself to handle the conversion during submission. That way the customer still sees the checkout in their own currency and you
don't need to interfere with normal currency handling otherwise.
Here's how it's done in the Authorize.net AIM module:
https://github.com/zencart/zencart/b....php#L396-L403
Obviously you'll need to adjust the specifics for however your gateway prepares its fields for transmission, but this shows you the basics of the calculation logic.
Excellent - thanks Doc!