The other day I found an obscure bug in the way AbleCommerce sums pricing for
totals and subtotals.  In my case, it exhibited itself when I discounted an ite
m
using a 10% discount.  This caused products to have three decimal places in the
discounted price ($14.95 discounted 10% is $13.455).  The ExtPrice field in
OrderOptions thinks the price is $13.455 (which technically it is) but it is
rounded to $13.46 when it is displayed in the shopping cart.  Now consider wh
en
you add another discounted book to the shopping cart.  They both get rounded up
to $13.46.  The subtotal line should read $26.92.  However, the subtotal 
line
displays $26.91.  Technically, this is correct since it is adding 13.455 +
13.455.  While this penny might not seem like much, I for one am not going to
try telling that to the accounting department.  :)  


If you purchased the source version as we did, you can change the following in
showcott.cfm in the basket.  This may not be the best coding solution, but it
works.


Original SubTotal query:

<cfquery name = "subtotal" datasource = "#ACBMainDS#">
SELECT  Sum (OrderDetails.ExtPrice) AS SubtotalPrice
FROM        OrderDetails
WHERE       Order_ID = #Showcont.Order_ID# AND Product_ID < 100000</cfquery>


New SubTotal query:

<cfquery name = "tempSubtotal" datasource = "#ACBMainDS#">
SELECT  OrderDetails.ExtPrice
FROM        OrderDetails
WHERE       Order_ID = #Showcont.Order_ID# AND Product_ID < 100000</cfquery>

<cfset SubtotalPrice = 0>
<cfloop query="tempSubtotal">
<cfif SubtotalPrice eq 0><cfset SubtotalPrice=
(#evaluate((round(#tempSubtotal.ExtPrice#*100))/100)#)>
<cfelse>
<cfset SubtotalPrice = (#evaluate(SubtotalPrice +
((round(#tempSubtotal.ExtPrice#*100))/100))#)>
</cfif>
</cfloop>


Use the same basic idea for the Total query (leave the original Total query in
there just to total the weight).  Finally, change Subtotal.SubtotalPrice to
SubtotalPrice and Total.TotalPrice to TotalPrice on the lines which actually
output the subtotal and total.

Good Luck!
________________________________________________________________
Jeff Langevin                          Appalachian Mountain Club
MIS Department         5 Joy Street, Boston, Massachusetts 02108
617-523-0655 x302                        http://www.outdoors.org


If one advances confidently in the direction of his dreams,
and endeavors to live the life which he has imagined,
he will meet with success unexpected in common hours.

-- Henry David Thoreau
______________________________________________________________________
Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation � $99/Month � Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusiona
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to