Zen Cart Logo
Forums / General Questions / Help with Cart total / order sub total

Help with Cart total / order sub total

Views: 967

Results 1 to 4 of 4
18 Dec 2012, 1:41 PM
#1
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Help with Cart total / order sub total

Hi all, I am hoping someone can help me. I am running v1.3.9h, when I have a sale applied to the store because it is a percentage off the items are rounded in the displaying in the store and in cart but when then cart total and checkout subtotal is addeded up it adds up the un-rounded figures. This causes sometimes for the total to be a penny out and causes PayPal website payments standard to not create the order.

Can anyone point me to where the code is that calculates the cart total and subtotals in checkout so I can look to change so it adds up the rounded figures instead of the plain figures so it all matches up?

Or if anyone knows of a better way to resolve this? Perhaps change the way the sale is calculated?

Please don't say just use express checkout because I do not wish to use express. I am happy with WPS all apart from the I'd order that isn't going through because of this issue.

Many thanks.
Phil

18 Dec 2012, 4:05 PM
#2
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Help with Cart total / order sub total

ok so just found this code in includes/functions/functions_prices.php

 if (!$special_price) {
        return number_format($sale_product_price, 4, '.', '');
      } else {
        switch($sale->fields['sale_specials_condition']){
          case 0:
            return number_format($sale_product_price, 4, '.', '');
            break;
          case 1:
            return number_format($special_price, 4, '.', '');
            break;
          case 2:
            return number_format($sale_special_price, 4, '.', '');
            break;
          default:
            return number_format($special_price, 4, '.', '');
        }
      }

changed it to:

 if (!$special_price) {
        return number_format($sale_product_price, 2, '.', '');
      } else {
        switch($sale->fields['sale_specials_condition']){
          case 0:
            return number_format($sale_product_price, 2, '.', '');
            break;
          case 1:
            return number_format($special_price, 2, '.', '');
            break;
          case 2:
            return number_format($sale_special_price, 2, '.', '');
            break;
          default:
            return number_format($special_price, 2, '.', '');
        }
      }

seems to have done the trick! Any one know why this might be a bad thing to do and if it could produce a different problem please let me know.

19 Dec 2012, 10:43 AM
#3
drbyte avatar

drbyte

Sensei

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

Re: Help with Cart total / order sub total

It might work for your unique situation, with your unique combination of tax rates and discounts/specials and your particular product prices and your particular demographic of customer who buys only a small number of any given item.

It's not a suitable solution for universal use, especially if a store has products priced to many more decimal places or deals in large quantities. In those cases your changes would cause more pricing errors.

19 Dec 2012, 10:46 AM
#4
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Help with Cart total / order sub total

DrByte:

It might work for your unique situation, with your unique combination of tax rates and discounts/specials and your particular product prices and your particular demographic of customer who buys only a small number of any given item.

It's not a suitable solution for universal use, especially if a store has products priced to many more decimal places or deals in large quantities. In those cases your changes would cause more pricing errors.

Thanks for letting me know :-) ill keep an eye on it but seems to have worked for me, recreated 2 of the orders that didn't work before and now they work :-)