Page 1 of 2 12 LastLast
Results 1 to 10 of 58

Hybrid View

  1. #1
    Join Date
    Nov 2006
    Posts
    108
    Plugin Contributions
    0

    Default Different Total Displayed

    On Zen Cart 1.5.7d and 1.5.8.
    I recently set up taxes for all products. Before I did not do this and this problem did not exist.

    I have a product with a net price of 945.4545.
    There is 10% tax, so the gross price is 1040.
    There is no decimal for the currency I use.

    When I put one of this item in the cart, the price displayed during checkout, email and invoice is 1040.
    When I put two of those products in the cart, the price in the shopping cart is 2080, at the checkout_payment, checkout_confirmation, mail and invoice it is 2079. Obviously this is wrong and it should be 2080.

    Anybody has any idea how to fix this?

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,547
    Plugin Contributions
    89

    Default Re: Different Total Displayed

    Thanks for the report. While I don't know how to fix this yet, I will soon.

  3. #3
    Join Date
    Jun 2008
    Location
    Japan
    Posts
    130
    Plugin Contributions
    5

    Default Re: Different Total Displayed

    Hi,
    I see this problem in my shop from time to time. Although I started investigating, I never got the end of it. Here is where I was:
    Successful orders are saved in database and particularly prices for each products are saved in table 'orders_products'. There are saved without tax in field 'products_price' with 4 decimal digits and in field 'final_price' where rounded to 0 decimal as per shop setting.
    Problem seems to be that this rounded value is used when creating invoice (from database) before applying tax.
    A possible solutions would be to save prices tax included... Another one could be to not do any rounding when saving final price. The second one seems easier as there is just to change line 659 in class file 'order.php' but I am not sure of what would be displayed.
    I need to do some testing...

  4. #4
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,547
    Plugin Contributions
    89

    Default Re: Different Total Displayed

    Yes, I believe that calculation (and, obviously, rounding) differences on product pricing need to be different when products-are-displayed-with-tax.

  5. #5
    Join Date
    Nov 2006
    Posts
    108
    Plugin Contributions
    0

    Default Re: Different Total Displayed

    Hi pilou2,
    Quote Originally Posted by pilou2 View Post
    Successful orders are saved in database and particularly prices for each products are saved in table 'orders_products'. There are saved without tax in field 'products_price' with 4 decimal digits and in field 'final_price' where rounded to 0 decimal as per shop setting.
    Problem seems to be that this rounded value is used when creating invoice (from database) before applying tax.
    You are right; that seems to be the origin of the error.
    Quote Originally Posted by pilou2 View Post
    A possible solutions would be to save prices tax included... Another one could be to not do any rounding when saving final price. The second one seems easier as there is just to change line 659 in class file 'order.php' but I am not sure of what would be displayed.
    I need to do some testing...
    I am not sure why in table orders_products products_price is saved with four decimals while final_price is saved as a rounded value.

    The data for total and subtotal for the invoice is pulled from the table orders_total. In this table the value for subtotal is saved rounded and the total value is saved not-rounded.
    It seems there is some inconsistency if values are saved rounded or not-rounded.

  6. #6
    Join Date
    Jun 2008
    Location
    Japan
    Posts
    130
    Plugin Contributions
    5

    Default Re: Different Total Displayed

    Quote Originally Posted by todoonada View Post
    ...I am not sure why in table orders_products products_price is saved with four decimals while final_price is saved as a rounded value...
    Many currencies use two decimals. Using four prevents loosing precision.

    Quote Originally Posted by todoonada View Post
    ..
    The data for total and subtotal for the invoice is pulled from the table orders_total. In this table the value for subtotal is saved rounded and the total value is saved not-rounded.
    It seems there is some inconsistency if values are saved rounded or not-rounded.
    It is not what I have here. In my orders_total table, all numbers (product price, shipping fees, tax, sub-total and total) are saved as displayed in 'text' field and as number not rounded and with four decimals in field 'value' .

  7. #7
    Join Date
    Nov 2006
    Posts
    108
    Plugin Contributions
    0

    Default Re: Different Total Displayed

    Quote Originally Posted by pilou2 View Post
    Many currencies use two decimals. Using four prevents loosing precision.
    With "table orders_products products_price is saved with four decimals" I meant that the value is not rounded.


    Quote Originally Posted by pilou2 View Post
    here is what I did:
    Replacing line 659 in ..\includes\classes\order.php
    I can confirm that it works. Yet I am not sure if the code change will have any other complications. There should be a reason why the author of the code rounded the value.

  8. #8
    Join Date
    Jun 2008
    Location
    Japan
    Posts
    130
    Plugin Contributions
    5

    Default Re: Different Total Displayed

    I tried saving final-price not rounded in database and it fixed it. I tried both with option to display with tax or not and checked for other possible consequences using developper tool in admin and so far all is good.

    here is what I did:
    Replacing line 659 in ..\includes\classes\order.php
    PHP Code:
    'final_price' => zen_round($products[$i]['price'] + $_SESSION['cart']->attributes_price($products[$i]['id']), $decimals), 
    by this:
    PHP Code:
    'final_price' => $products[$i]['price'] + $_SESSION['cart']->attributes_price($products[$i]['id']), 
    Now, invoices and emails are as they should be.

  9. #9
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,547
    Plugin Contributions
    89

    Default Re: Different Total Displayed

    Quote Originally Posted by todoonada View Post
    On Zen Cart 1.5.7d and 1.5.8.
    I recently set up taxes for all products. Before I did not do this and this problem did not exist.

    I have a product with a net price of 945.4545.
    There is 10% tax, so the gross price is 1040.
    There is no decimal for the currency I use.

    When I put one of this item in the cart, the price displayed during checkout, email and invoice is 1040.
    When I put two of those products in the cart, the price in the shopping cart is 2080, at the checkout_payment, checkout_confirmation, mail and invoice it is 2079. Obviously this is wrong and it should be 2080.

    Anybody has any idea how to fix this?
    @todonada, have you tested to see if the code in the current GitHub master branch (https://github.com/zencart/zencart) corrects this issue? I'm pretty sure that this was one of the test cases I used when making those pricing-calculation updates.

  10. #10
    Join Date
    Nov 2006
    Posts
    108
    Plugin Contributions
    0

    Default Re: Different Total Displayed

    Quote Originally Posted by lat9 View Post
    @todonada, have you tested to see if the code in the current GitHub master branch (https://github.com/zencart/zencart) corrects this issue? I'm pretty sure that this was one of the test cases I used when making those pricing-calculation updates.
    Sorry for the late reply!

    I applied the changes described here
    https://github.com/lat9/zencart/comm...44631fc0b06cba
    and here
    https://github.com/zencart/zencart/pull/6141/files

    So far everything seems to work fine and the problem from the initial post is solved thanks to your code changes.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 5
    Last Post: 3 Apr 2020, 07:53 PM
  2. v151 Site that displayed different templates.
    By Malaperth in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 3 Feb 2014, 07:38 PM
  3. v151 order total different from cart total
    By s_p_ike in forum Bug Reports
    Replies: 9
    Last Post: 9 Dec 2012, 09:29 AM
  4. Different Product Listing styles displayed
    By skelly100 in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 31 Dec 2009, 11:33 PM
  5. Free shipping for Different sales total for different zones
    By francesca_ph in forum Built-in Shipping and Payment Modules
    Replies: 20
    Last Post: 30 Dec 2008, 05:43 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR