Orders - calculating wrong total

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
curlypinky
Forum Members
Forum Members
Posts: 109
Joined: Thu Sep 04, 2008 3:49 am
Location: Hawaii

Orders - calculating wrong total

Post by curlypinky »

I'm having some trouble with the Orders module amount totaling function. It seems to be calculating the order total wrong. Calculation methods in the frontend are working, the values it passes to the paypal gateway are correct but in the backend it is calculating the item totals wrong.
So in this example I have 3 of the same items @ $18/ea total $54, shipping $5 and tax $2.25. The total should be $61.25 (which is what is passed to PayPal) but in orders it says the total is $169.25. It is doing this with all orders.
I've included a snapshot of the invoice view to illustrate.

The problem is something to do with the master_price portion of the sub_total function, I commented out lines 271-275 of class_orders_shipping.php

Code: Select all

 $master_price = $item->get_master_price();
	    if( !empty($master_price) ) 
	      {
		$subtotal2 = $item->get_quantity() * $master_price;
	      }
And this corrected the amount on the detail view, though the Orders list view is still displaying the wrong amounts.
Thanks,
Alane
Attachments
bad_invoice_example.jpg
curlypinky
Forum Members
Forum Members
Posts: 109
Joined: Thu Sep 04, 2008 3:49 am
Location: Hawaii

Re: Orders - calculating wrong total

Post by curlypinky »

Whoops forgot to include my system info:

----------------------------------------------

Cms Version: 1.9.2

Installed Modules:

    * CMSMailer: 2.0
    * FileManager: 1.0.3
    * MenuManager: 1.7.4
    * ModuleManager: 1.4
    * News: 2.11
    * nuSOAP: 1.0.2
    * Printing: 1.1.1
    * Search: 1.6.8
    * ThemeManager: 1.1.3
    * TinyMCE: 2.8.2
    * CGExtensions: 1.22
    * FrontEndUsers: 1.12.8
    * CGSimpleSmarty: 1.4.5
    * Products: 2.9.1
    * CGEcommerceBase: 1.2.3
    * Cart: 1.7.4
    * CGPaymentGatewayBase: 1.0.9
    * Orders: 1.10.6
    * Banners: 2.3.6
    * Gallery: 1.4.3
    * CGCalendar: 1.5.6
    * NMS: 2.3.2
    * NMSTrack: 1.0
    * TemplateExternalizer: 1.2
    * FormBuilder: 0.6.4
    * SelfRegistration: 1.6.7
    * Uploads: 1.11.5
    * CustomContent: 1.7.3
    * FEUMailer: 0.9.3
    * CGUserDirectory: 1.2.4
    * Play: 1.0.3
    * FRShipping: 1.2.1
    * PaypalGateway: 2.2.1
    * warehouse_taxes: 1.2


Config Information:

    * php_memory_limit:
    * process_whole_template: false
    * output_compression: false
    * max_upload_size: 200000000
    * default_upload_permission: 664
    * url_rewriting: mod_rewrite
    * page_extension: .html
    * query_var: page
    * image_manipulation_prog: GD
    * auto_alias_content: true
    * locale:
    * default_encoding: utf-8
    * admin_encoding: utf-8
    * set_names: true


Php Information:

    * phpversion: 5.2.14
    * md5_function: On (True)
    * gd_version: 2
    * tempnam_function: On (True)
    * magic_quotes_runtime: Off (False)
    * E_STRICT: 0
    * memory_limit: 128M
    * max_execution_time: 120
    * output_buffering: On
    * safe_mode: Off (False)
    * file_uploads: On (True)
    * post_max_size: 32M
    * upload_max_filesize: 32M
    * session_save_path: /tmp (1777)
    * session_use_cookies: On (True)
    * xml_function: On (True)


Server Information:

    * Server Api: cgi
    * Server Db Type: MySQL (mysql)
    * Server Db Version: 5.0.91


----------------------------------------------
curlypinky
Forum Members
Forum Members
Posts: 109
Joined: Thu Sep 04, 2008 3:49 am
Location: Hawaii

Re: Orders - calculating wrong total

Post by curlypinky »

Well I've hunted around Orders 1.10.6 but my coding is weak, I can't figure out what subtotal function the Orders tab list view is using. But I think this is a legitimate bug, I am going to file a bug report.
User avatar
jd447
Forum Members
Forum Members
Posts: 134
Joined: Wed Jun 20, 2007 7:06 am
Location: geneva

Re: Orders - calculating wrong total

Post by jd447 »

same here... as soon as i've got more that one article, the total is wrong. seems like it multiplies twice the articles.
________________________
http://www.pixinside.ch
curlypinky
Forum Members
Forum Members
Posts: 109
Joined: Thu Sep 04, 2008 3:49 am
Location: Hawaii

Re: Orders - calculating wrong total

Post by curlypinky »

Yes, as far as I can see it is stemming from

Code: Select all

$subtotal2 = $item->get_quantity() * $master_price;
If you look at your DB, master_price's value seems to already be calculated as unit_price * quantity so if you have >1 of the same items you're ending up with subtotal2 being calculated like (unitprice*quan)*quan.
And since $subtotal is choosing the higher of subtotal1 and subtotal2 we get the wrong total for orders where we have quantities greater than 1.

I have filed a bug report for Orders about this and hoping for an update, I'm sure the dev calguy is busy with the holidays and all.

Alane
User avatar
jd447
Forum Members
Forum Members
Posts: 134
Joined: Wed Jun 20, 2007 7:06 am
Location: geneva

Re: Orders - calculating wrong total

Post by jd447 »

did you find any solutions for that issue curly?
curlypinky
Forum Members
Forum Members
Posts: 109
Joined: Thu Sep 04, 2008 3:49 am
Location: Hawaii

Re: Orders - calculating wrong total

Post by curlypinky »

Sorry JD, no module updates have been released, I did file a bug report to the Orders module project.
I am surprised no one else is experiencing this. Did you have a fresh install of the latest Orders or did you upgrade from an earlier version? I had upgraded from an install that was several months old (if I remember correct :P ) It was before the ability to checkout without an account was added, so all my templates were awry. I wonder if there is something about an older install. Just a thought. I have a new installation of Orders on another site so I will be able to test that soon.

Alane
User avatar
jd447
Forum Members
Forum Members
Posts: 134
Joined: Wed Jun 20, 2007 7:06 am
Location: geneva

Re: Orders - calculating wrong total

Post by jd447 »

I experienced the problem with a fresh install.

i also reported the bug with my config and i'm also surprised that it's just the two of us experiencing this issue. let's hope that calguy will have some time to fix this issue.
maranc
Forum Members
Forum Members
Posts: 249
Joined: Tue May 04, 2010 5:04 pm

Re: Orders - calculating wrong total

Post by maranc »

I can confirm that here is this bug (I will later report about few issue in templates). BTW - fast solution to change amount and to have it correct:
http://www.pengoworks.com/workshop/jque ... plugin.htm

I tested action with Paypal and what is strange - amount witch is sending to Paypal is correct.

Marek A.
maranc
Forum Members
Forum Members
Posts: 249
Joined: Tue May 04, 2010 5:04 pm

Re: Orders - calculating wrong total

Post by maranc »

OK, here is my solution: replace code funnction get_subtotal for bellow:

[edited by moderator]

Best regards,
Marek A.
User avatar
jd447
Forum Members
Forum Members
Posts: 134
Joined: Wed Jun 20, 2007 7:06 am
Location: geneva

Re: Orders - calculating wrong total

Post by jd447 »

why was that edited by a moderator???
curlypinky
Forum Members
Forum Members
Posts: 109
Joined: Thu Sep 04, 2008 3:49 am
Location: Hawaii

Re: Orders - calculating wrong total

Post by curlypinky »

Hi folks,

In the case of Marek's edits to Orders' code it is against forum policy now to post php code edits to the core or modules (good or bad). Don't get upset - I can understand dev's stance on this - when we start hacking our installs then our version is no longer the developers version. If we then have a problem and ask for help we are asking for help on software that no longer represents the developer's version. Chaos and anarchy ensues and then burning and looting in the streets. OK, well maybe not that far :) , but it definitely makes things harder for developers to have to monitor forum and forge for legit bugs and deal with requests for help on hacked software. Both I and Marek have included what we have found in the forge bug report so best we can do is include as detailed of info as we can in that report thread and wait for the next release.

Cheers,
Alane
Post Reply

Return to “Modules/Add-Ons”