Ecommerce software home
Shopping Cart Software Forum for Ecommerce Templates
 
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

Find us on Facebook Follow us on Twitter View our YouTube channel
Search our site
 All Forums
 Technical
 PHP (Unix / Linux / Apache) versions
 0.00 = 1.4210854715202E-14?
Author « Topic »  

Fingertech
Advanced Member

Canada
317 Posts

Posted - 04/17/2019 :  14:29:12  
We are having trouble with some simple addition of database cells not equaling zero. Does ECT do something funky with its maths? Or is it the XML line here that is causing the issue?

echo " <OrderTotal>" . ($rs['ordTotal']+$rs['ordStateTax']+$rs['ordCountryTax']+$rs['ordHSTTax']+$rs['ordShipping']-$rs['ordDiscount']) . "</OrderTotal>";
Where:
ordTotal = 38.28
orderStateTax = 0.00
ordCountryTax = 0.00
ordHSTTax = 0.00
ordShipping = 52.74
ordDiscount = 91.02

These should all add up to zero, but OrderTotal for some reason is 1.4210854715202E-14. This causes trouble when importing to Shipstation. It has been happening since the beginning so not something new.
Any idea where to look for the error?

Thanks.

dbdave
ECT Moderator

USA
10276 Posts

Posted - 04/17/2019 :  14:46:19  
Do your products have options, and if so, do the options impact the pricing?
I recall my Shipstation (I am on .asp) not handling order totals correctly, but it seems like it was related to product options.
I ended up edited the scripts and striped that stuff out.
I don't need ship station keeping track of every penny we take in.

Fingertech
Advanced Member

Canada
317 Posts

Posted - 04/17/2019 :  14:55:00  
Thanks for the reply Dave!

This order has no options. And for ShipStation those only factor into the unit prices, not the totals. So I don't think that holds the answer.

dbdave
ECT Moderator

USA
10276 Posts

Posted - 04/17/2019 :  15:19:47  
I would just create a .php test page and with an sql statement to see what's returned.
Obviously the store is working arithmetic correctly.
I was recently working with some of this (this tip I posted) https://www.ecommercetemplates.com/support/topic.asp?TOPIC_ID=111261 and the cart handles this type of thing in a very straightforward way, so I would point the "finger" at the shipstation script first.

Fingertech
Advanced Member

Canada
317 Posts

Posted - 04/17/2019 :  21:22:09  
quote:
create a .php test page and with an sql statement to see what's returned.

You're already past what I know how to do!

I would also think ECT works in a straightforward manner, but the ShipStation XML file is really just that one line to calculate the OrderTotal:
$rs['ordTotal']+$rs['ordStateTax']+$rs['ordCountryTax']+$rs['ordHSTTax']+$rs['ordShipping']-$rs['ordDiscount']
I don't see how that could be a problem.

One thing that has me thinking it's ECT is that often, in Order Admin when I add a discount to a customer's order equal to the order amount, instead of making the total = $0.00, it makes the total $-0.00. So to me it looks like ECT is rounding things. You think no? Can the php test page you suggested tell us for certain?

Andy
ECT Moderator

95440 Posts

Posted - 04/17/2019 :  23:59:32  
Hi

I'm not an expert on this but it may be how PHP in general handles rounding rather than the arithmetic from ECT. Maybe someone with greater knowledge of the workings of PHP could confirm that for me.

Andy

Please feel free to review / rate our software
  « Topic »  
Jump To:
Shopping Cart Software Forum for Ecommerce Templates © 2002-2022 ecommercetemplates.com
This page was generated in 0.03 seconds. Snitz Forums 2000