personally, i am a BIG fan of this approach.
i applaud @lat9 in getting this code into some sort of workable shape, but i have found EMP to be a good solution for admins needing to enter customer orders.
Printable View
Ran another test case involving group discount and not quantity discount. In this case I ordered a non-quantity discountable but group discountable product on the store side, and added another non-quantity discountable but group discountable item in EO. At EO entry, subtotal, group discount, shipping, tax and total were all correct. After adding the product in EO, the subtotal, group discount, and shipping were correct. The tax was too high by 1 cent, and the total was incorrect. After clicking update, the tax was still off by one cent, and the total was the correct total for the subtotal, group discount, shipping and tax shown.
The total was NOT too low by the discount as seen in tests involving quantity discount. So EO is not encountering the problem with group discounts.
I suspect the tax error was caused by rounding up rather than rounding down somewhere. Repeating the order on the store side gave the correct tax.
Ran another test with both quantity discount and group discount involved. In this test, I ordered a non-quantity discountable product and a quantity-discountable product on the store-side. Both products subject to group discount. Subtotal, quantity discount, group discount, shipping, tax and order total were correct. After EO entry, the totals were all the same. Now, instead of adding any products, I just clicked update. The subtotal, quantity discount, group discount, shipping and tax were correct. The total was too low by an amount that equals the tax on the sum of the quantity discount and member discount!
So something goes wrong when update is clicked and a quantity discount is present. It doesn't matter if the quantity discount product was added by EO or was in the original order, the result is that the order total is too low by the sum of quantity and group discounts. If group discount is not present, the total is too low by the tax on the quantity discount. I have no way of seeing if any other discount types affect the total.
As a side note, on the EO page, the quantity discount is editable and in a box. There is no minus sign displayed and the number is displayed to four places to the right of the decimal point. The group discount is not editable, there is a minus sign and no box. The value is displayed with two decimal places. Not sure if this is significant to the problem at hand.
With edits...
Ran another test with both quantity discount and group discount involved. In this test, I ordered a non-quantity discountable product and a quantity-discountable product on the store-side. Both products were subject to group discount. Subtotal, quantity discount, group discount, shipping, tax and order total were all correct. After EO entry, the totals were all the same and correct. Now, instead of adding any products, I just clicked update. The subtotal, quantity discount, group discount, shipping and tax were all correct. The total was too low by an amount that equals the tax on the sum of the quantity discount and member discount!
So something goes wrong when update is clicked and a quantity discount is present. It doesn't matter if the quantity discount product was added by EO or was in the original order, the result is that the order total is too low by the tax on the sum of quantity and group discounts. If group discount is not present, the total is too low by the tax on the quantity discount. I have no way of seeing if any other discount types affect the total.
As a side note, on the EO page, the quantity discount is editable and in a box. There is no minus sign displayed and the number is displayed to four places to the right of the decimal point. The group discount is not editable, there is a minus sign and no box. The value is displayed with two decimal places. Not sure if this is significant to the problem at hand.
carlwhat,
I also am very grateful to lat9 for what she has done with Edit Orders. But the issue being addressed is not Admin New Order or EMP any longer. The issue is incorrect order totals when a quantity discount is present. And we still have not found out if the problem is in Quantity Discount or in EO. Thank you for your endorsement of EMP.
@Dave224, I appreciate the testing that you're doing to identify the issue(s) but the information you've supplied so far doesn't have enough information for me to replicate. You've probably identified some of this before, but a consolidation is appreciated:
Zen Cart version
EO version
Plugins installed (name/version)
When you click "Update" are you also ticking the "Recalculate totals" checkbox?
ZC 1.5.5e
edit_orders v4.3.1 (without your proposed mod in EO support thread post #1182, so as-released EO 4.3.1)
quantity discount v1.11 (with mod in quantity discount support thread post #805 and my discount categories, levels and amounts)
admin_new_customer v1.4
admin_new_order v1.4.1 (with mods to avoid calling ot_tax.php)
stock_by_attribute v1.5.3
shipping_by_quote v2.3
product_cost_display v1.1.0
Recalculate totals checkbox is ticked by default.
Hope this helps.
EO settings follow:
Edit Orders Version: 4.3.1
Reset Totals on Update-Default: on
Use a mock shopping cart: true
Strip tags from the shipping module name: true
Debug Action Level: 1
Quantity Discount settings follow:
This module is installed: true
Sort Order: 200
Include Tax: false
Re-calculate Tax: Standard
Discount Units: currency per item
Discount Basis: Total By Category
Counting Method: items
Discount Level 1: 5
Discount Amount 1: .25
Discount Level 2: 13
Discount Amount 2: .5
Discount Level 3: 25
Discount Amount 3: .75
Discount Level 4: 0
Discount Amount 4: 0
Discount Level 5: 0
Discount Amount 5: 0
The product I have been testing with is subject to a special discounting policy in includes/modules/order_total/ot_quantity_discount.php. See code fragment below:
This gives $1.00 off the price per item if five or more items are purchased. The discount levels and amounts in quantity discount settings apply to another discountable product category, but I have not used that product category in my testing to date.Code:function apply_special_category_discount($category, $count, &$disc_amount) {
switch ($category) {
case 102:
if ($count > 4) {
$disc_amount = 1.00; // discount from sale price
}
break;
case 99997:
$disc_amount = 75;
break;
}
There are no attributes associated with any of the products eligible for quantity discounts.
Also, please note the product I have been testing with has a Specials price at 50% off. The normal price is $6.00 per item, the special sale price is $3.00 per item, so if five or more items are purchased, the price is $2.00 per item. I don't think this special price makes any difference, but the information is provided for full disclosure.
There is only one tax class, a state sales tax of 6% based on where the item ships. The product I have been testing with is taxable and the dummy customer lives in the state with the tax.
I hope this helps with trying to replicate the problem.