Hi,
Thanks for the reply.
This problem is to do with converting the data from the Australia Post calculator with is always returned in AUD to whatever the delault currency is set to by the Admin menu.
It has nothing to do with what currency the customer has selected to display in.
I have set my default (base) curreny to USD. I cannot add a postage cost to to the tolat cost without converting it to my default curreny first. Once that is done the customer can view it in any currency they like.
To show the point, below is a code snippet from line 126 in auspostair.php.
Code:
'cost' => ($shipping_auspostair_cost + MODULE_SHIPPING_AUSPOSTAIR_HANDLING) + $insurance)));
$shipping_auspostair_cost is returned from the Australia Post calculator. It is in AUD.
$insurance and MODULE_SHIPPING_AUSPOSTAIR_HANDLING are in the ZC default curreny I set, i.e. USD
As I was taught in primary school, "You can't add apples and oranges". It is stange that no one has picked this up before.
Anyhow, this morning I managed to fumble through php and work it out.
What I've done is replaced line 112 where $charge is the value returned by the Australian Post calculator;
Code:
$shipping_auspostair_cost = $charge;
with;
Code:
global $currencies;
// $shipping_auspostair_cost = $charge;
// Change the value returned by the calculator to the default currency.
$aus_rate = $currencies->get_value(AUD);
$shipping_auspostair_cost = $charge/$aus_rate;
I'm not too sure how "PHP correct" correct what I have done is but it works. It should work no matter what the default currency is.
At the moment the Australia Post shipping module only works if the default currency is AUD. I presume that this problem also occurs with the Canadian Shipping module, the UPS shipping module as well.
I cannot believe that this issue has not come up before. It is a problem that will occur whenever an external calculator is called that returns a value that is not in the default currency.
Anyhow I managed to solve it myself, albeit a lot of unproductive effort was required.
Cheers,
Peter.
Bookmarks