Forums / Bug Reports / Correct price for a quantity of products

Correct price for a quantity of products

Locked

Started by kalastaja on 21 Nov 2010, 7:13 PM · Views: 2,257

Results 1 to 18 of 18
This thread is locked. New replies are disabled.
21 Nov 2010, 7:13 PM
#1
kalastaja avatar

kalastaja

Zen Follower

Join Date:
Mar 2010
Location:
Finland
Posts:
465
Plugin Contributions:
0

Correct price for a quantity of products

Is there any way to make sure that e.g. 10 pcs of a products that "seems" to cost 1.25 (reality 1.2534) becomes 12.50 and NOT 12.53.
By introducing zen_round() to the function zen_add_tax($price, $tax) I get the shopping cart ok, but subtotal and thereby total still hangs (erroneously) on to the decimals.... I use 1.3.9h

25 Nov 2010, 10:10 AM
#2
kalastaja avatar

kalastaja

Zen Follower

Join Date:
Mar 2010
Location:
Finland
Posts:
465
Plugin Contributions:
0

Re: Correct price for a quantity of products

10 pcs of a products that "seems" to cost 1.25 (reality 1.2534) should become 12.50 and NOT 12.53.
By introducing zen_round() to the function zen_add_tax($price, $tax) I get the shopping cart ok, but subtotal and thereby total still hangs (erroneously) on to the decimals.... I use 1.3.9h

25 Nov 2010, 3:13 PM
#3
ajeh avatar

ajeh

Oba-san

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

Re: Correct price for a quantity of products

How much are 3 suppose to be?

How much are 5 suppose to be?

How much are 7 suppose to be? :unsure:

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!

25 Nov 2010, 3:37 PM
#4
kalastaja avatar

kalastaja

Zen Follower

Join Date:
Mar 2010
Location:
Finland
Posts:
465
Plugin Contributions:
0

Re: Correct price for a quantity of products

I used zen_round() when testing - hopefully it's working correctly.... The point was that the "extra" digits should be rounded BEFORE multiplying with quantity! As a reply to the "wise man":no:: as far as I know 1-4 goes down, 6-9 goes up and 5 goes to even.

26 Nov 2010, 8:20 PM
#5
kalastaja avatar

kalastaja

Zen Follower

Join Date:
Mar 2010
Location:
Finland
Posts:
465
Plugin Contributions:
0

Re: Correct price for a quantity of products

Anybody!?

26 Nov 2010, 8:32 PM
#6
ajeh avatar

ajeh

Oba-san

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

Re: Correct price for a quantity of products

You might try to directly answer the questions on post #3 ... it would help to know ...

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!

26 Nov 2010, 8:41 PM
#7
kalastaja avatar

kalastaja

Zen Follower

Join Date:
Mar 2010
Location:
Finland
Posts:
465
Plugin Contributions:
0

Re: Correct price for a quantity of products

What did I not answer? > as far as I know 1-4 goes down, 6-9 goes up and 5 goes to even
0.1-0.4 => 0
0.6-0.9 => 1
0.5 => 0

26 Nov 2010, 9:05 PM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Correct price for a quantity of products

Ajeh was talking about quantities, not "how does rounding work".

ie: if you have 3 items at 1.2534 or have 45 items at 1.2534, how exactly do you think the rounding should work then? There's a huge difference when you look at it that way.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

27 Nov 2010, 2:47 PM
#9
kalastaja avatar

kalastaja

Zen Follower

Join Date:
Mar 2010
Location:
Finland
Posts:
465
Plugin Contributions:
0

Re: Correct price for a quantity of products

There's NO DIFFERENCE: Quite simple, if the product price is shown as 1.25 (although adding tax has made it actually 1.2543) it's 1.25 - it doesn't matter how many products you buy, the unit price should be 1.25! (3pcs 3.75, 45pcs 56.25)

The problem arises, as you well know, because it stores the price **without ** taxes and then adds the tax "on the fly" if so requested. So if the price (with no tax) contains cents and the tax is a number (almost anything but a 100%) you get fractions of a cent - e.g. 1.11 * 1.13 (13% tax) = 1.2543 AND this is shown as a unit price of 1.25 when you look at the product (as it should)! BUT when you buy 10 pcs, the price is suddenly 12.54:frusty: - not much, but it makes the shop look "adequate" not good!

And I managed to get it half right - as I said: > By introducing zen_round() to the function zen_add_tax($price, $tax) I get the shopping cart ok, but subtotal and thereby total still hangs (erroneously) on to the decimals.

PS. Nice that you "wise" guys stick together....

27 Nov 2010, 3:03 PM
#10
kalastaja avatar

kalastaja

Zen Follower

Join Date:
Mar 2010
Location:
Finland
Posts:
465
Plugin Contributions:
0

Re: Correct price for a quantity of products

PPS. THE POINT being that if the price is defined to have e.g. 2 decimals, that should determine the rounding - I mean that's why it's there, isn't it?

27 Nov 2010, 3:28 PM
#11
ajeh avatar

ajeh

Oba-san

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

Re: Correct price for a quantity of products

When you edit the Product, is the Product Price entered as:
1.25

or are you entering it as:
1.2543

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!

27 Nov 2010, 3:34 PM
#12
kalastaja avatar

kalastaja

Zen Follower

Join Date:
Mar 2010
Location:
Finland
Posts:
465
Plugin Contributions:
0

Re: Correct price for a quantity of products

I enter it as 1.11 !!!!!!!!! The 13% sales tax makes it 1.2543.

28 Nov 2010, 11:25 AM
#13
kalastaja avatar

kalastaja

Zen Follower

Join Date:
Mar 2010
Location:
Finland
Posts:
465
Plugin Contributions:
0

Re: Correct price for a quantity of products

Dear Sirs,

I am reporting a bug, not stating an opinion!

28 Nov 2010, 2:45 PM
#14
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Correct price for a quantity of products

kalastaja:

Dear Sirs,

I am reporting a bug, not stating an opinion!It's not a bug, and it is an opinion, albeit implict, that the cart should work in the specific way that favors the way your tax regime and pricing are setup over all others.

Enter the price as 1.1062 instead of 1.11 as Zen Cart intends and your problem will go away.

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

28 Nov 2010, 3:32 PM
#15
kalastaja avatar

kalastaja

Zen Follower

Join Date:
Mar 2010
Location:
Finland
Posts:
465
Plugin Contributions:
0

Re: Correct price for a quantity of products

Whoops. I rechecked and - my humble apologies - only the TAX decimals are defined. Not to worry big guys, if I can't get a hint from you which function to edit - I'll figure it out myself.... My shop already has e.g. a cash-back-functionality (based on the profit, so there is a buyin_price, etc.), phpNuke as backoffice...

28 Nov 2010, 3:44 PM
#16
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Correct price for a quantity of products

kalastaja:

if I can't get a hint from you which function to edit ...There's no need to edit any function. Just calculate your pre-tax prices with sufficient precision that they come back to the tax-inclusive price that you want.

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

28 Nov 2010, 4:11 PM
#17
kalastaja avatar

kalastaja

Zen Follower

Join Date:
Mar 2010
Location:
Finland
Posts:
465
Plugin Contributions:
0

Re: Correct price for a quantity of products

Flashback: me recalculating over 2000 items, of which the buyin price can anyway change at any moment - normally this is multiplied with the pricing factor to get the net price and after adding (different taxes for different product types) voilá the gross price is there.

OR

Me editing a function (or functions) that handle the price and how it's shown.

I wonder.....

9 Dec 2010, 11:26 AM
#18
kalastaja avatar

kalastaja

Zen Follower

Join Date:
Mar 2010
Location:
Finland
Posts:
465
Plugin Contributions:
0

Re: Correct price for a quantity of products

So you are telling me that if I see a price like 1.25 in a (ZenCart) shop, I should assume it might be anything like from 1.2451 to 1.2549!? Should I assume that this is true for all shops or is this just a ZenCart "feature"?

PS. This has nothing to do with any tax regime, it's more like a question of WYSIWYG!
PPS. Reverse engineering the price is the most unprofessional comment so far - that's not solving the problem, that's just putting out the eminent fire.....