CMS MADE SIMPLE FORGE

Orders

 

[#6103] Order total showing $0 on orders tab list

avatar
Created By: Alane Cole (curlypinky)
Date Submitted: Sat Feb 12 00:56:55 -0500 2011

Assigned To: Robert Campbell (calguy1000)
Version: 1.11.3
CMSMS Version: None
Severity: Major
Resolution: None
State: Open
Summary:
Order total showing $0 on orders tab list
Detailed Description:
Thank you for the new release! Updated and testing now, lovely! 
I am not using Promotions so the discount column is null for my orders. This is
causing the order total to return as 0 when you look at the orders list.
 
This can be corrected on line 114 of function.orders_tab.php to return 0 if
discount is null.

++++ original code: ++++
LEFT JOIN 
(SELECT order_id,
SUM(GREATEST(master_price,quantity*unit_price))+SUM(quantity*discount) AS total
                 FROM '.cms_db_prefix().'module_orders_items
                GROUP BY order_id) AS c 

++++ working correction: ++++
LEFT JOIN 
(SELECT order_id,
SUM(GREATEST(master_price,quantity*unit_price))+SUM(quantity*IFNULL(discount,0))
AS total
                 FROM '.cms_db_prefix().'module_orders_items
                GROUP BY order_id) AS c 

Thank you!
Alane


History

Comments
avatar
Date: 2011-02-15 11:14
Posted By: Robert Campbell (calguy1000)

I think you had an upgrade problem, as that's not the code I have.
      
avatar
Date: 2011-02-15 12:14
Posted By: marek a. (maranc)

Hmm ..., here is some strange ..  I upgraded module Orders yesterday and the
code provided by Alane Cole is exactly what I have too in this file (line 114).

Maybe here is problem with files in download?

Marek A.
      
avatar
Date: 2011-02-15 16:39
Posted By: Gary McPherson (Genyus)

I can confirm that I see the same bug and code in my instance
      
avatar
Date: 2011-02-18 01:07
Posted By: Alane Cole (curlypinky)

The 1.11.2 files available here in the forge have line 114 of 
function.orders_tab.php as:
(SELECT order_id,
SUM(GREATEST(master_price,quantity*unit_price))+SUM(quantity*discount) AS total

First I had upgraded using the Module Manager but then the orders totals were
still being displayed as 0 so I deleted the Orders folder and uploaded a
complete fresh copy of 1.11.2 straight from the forge to make sure I didn't have
any modified files messing things up.

Thank you!
      
avatar
Date: 2011-03-21 20:56
Posted By: Alane Cole (curlypinky)

I'm sorry, this issue is still affecting the most recent version of Orders - v.
1.11.3.
Now on line 120 of functions.orders_tab.php is causing the listing of the orders
to appear as 0 if any of the values involved with the calculations are NULL. For
example, I am not using Promotions so my discount column is always going to be
NULL. I also found this causes Tax and Shipping rows to be omitted from the
calculation because both these types of entries have a NULL masterprice. Using
IFNULL will make sure that the value is correctly calculated:

line 120-123:

$tmp = ' LEFT JOIN  
(SELECT order_id,
SUM(GREATEST(IFNULL(master_price,0),quantity*unit_price))+SUM(quantity*IFNULL(discount,0))
AS total
                 FROM '.cms_db_prefix().'module_orders_items
                GROUP BY order_id) AS c 

I downloaded 1.11.3 the package from the forge here to make sure I have the
current files.

Thanks!
Alane
      
Updates

Updated: 2011-03-21 20:56
version_id: 28898 => 28944

Updated: 2011-02-18 00:52
version_id: 28885 => 28898
resolution_id: 11 => 5

Updated: 2011-02-15 11:14
resolution_id: => 11