Forums / Bug Reports / Quantity and Final Price wrong with Portuguese Local

Quantity and Final Price wrong with Portuguese Local

Locked

Views: 851

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
27 Jun 2010, 3:10 PM
#1
diego_vieira avatar

diego_vieira

New Zenner

Join Date:
Nov 2008
Posts:
21
Plugin Contributions:
1

Quantity and Final Price wrong with Portuguese Local

When you set the locale to other language that has the decimal separator as "," and ZC is going to update the table orders_products, the final_price field is truncated.
eg. Products Price US$1.00 when exchange to BRL, let's say R$1,80.
So when you change the locale into the language file to

@setlocale(LC_ALL, 'pt_BR', 'pt_BR.iso-8859-1', 'pt_BR.utf-8', 'portuguese');

The price goes to 1,80 instead of 1.80
as a result, when the query is executed to insert the orders_products, the value is truncated to 1.00.

So I have to change the following:
At line 744 of includes/classes/order.php
changed

'final_price' => $this->products[$i]['final_price'],

to

'final_price' => str_replace(',', '.', $this->products[$i]['final_price']),

also, at line
734 of the same file, I have to change the line

$db->Execute("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%f', $this->products[$i]['qty']) . " where products_id = '" . zen_get_prid($this->products[$i]['id']) . "'");

back to

$db->Execute("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . zen_get_prid($order->products[$i]['id']) . "'");

because if you leave as "%f" instead of "%d" when inserting the products into orders_products, the following error comes:

1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '000000 where products_id = '1017'' at line 1
in:
[update zen_products set products_ordered = products_ordered + 1,000000 where products_id = '1017']

notice the 1,0000

hope that this makes sense.

27 Jun 2010, 3:17 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Quantity and Final Price wrong with Portuguese Local

What are your Currency settings for this?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

29 Jun 2010, 9:38 AM
#3
diego_vieira avatar

diego_vieira

New Zenner

Join Date:
Nov 2008
Posts:
21
Plugin Contributions:
1

Re: Quantity and Final Price wrong with Portuguese Local

here you go.