Zen Cart Logo
Forums / Addon Admin Tools / Edit Orders v4.0 Support Thread

Edit Orders v4.0 Support Thread

Views: 346,058

Results 1,221 to 1,240 of 1,927
11 Feb 2018, 4:26 PM
#1221
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,067
Plugin Contributions:
56

Edit Orders v4.0 Support Thread

Dave224:

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.
It's a start ...

In EO, are you using the default settings?
For Quantity Discounts, what are your settings?
Does the product in question use attributes? If so, are they under the control of SbA?

11 Feb 2018, 6:39 PM
#1222
dave224 avatar

dave224

Zen Follower

Join Date:
Jun 2012
Posts:
481
Plugin Contributions:
0

Re: Edit Orders v4.0 Support Thread

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:

   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;
      }

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.

There are no attributes associated with any of the products eligible for quantity discounts.

11 Feb 2018, 6:50 PM
#1223
dave224 avatar

dave224

Zen Follower

Join Date:
Jun 2012
Posts:
481
Plugin Contributions:
0

Re: Edit Orders v4.0 Support Thread

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.

11 Feb 2018, 6:57 PM
#1224
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,067
Plugin Contributions:
56

Re: Edit Orders v4.0 Support Thread

@Dave224, thanks for the update. I've replicated the issue with Quantity Discounts v1.12.1 (the current version available), EO 4.3.1 and zc1.5.5f.

I'll continue looking for a solution to the combination (Quantity Discounts/EO) but based on the specialized tax-handling that's present in Quantity Discounts, I'm not particularly hopeful that I'll find one.

11 Feb 2018, 7:51 PM
#1225
dave224 avatar

dave224

Zen Follower

Join Date:
Jun 2012
Posts:
481
Plugin Contributions:
0

Re: Edit Orders v4.0 Support Thread

Thank you for your continued efforts to find a solution. I will also continue to look.

Also, I made a mistake in the quantity discount version I am using. I am using v1.12.1 (the current version), not 1.11 (which is what I was using with zc v1.5.1). Sorry for any confusion.

13 Feb 2018, 11:05 PM
#1226
dave224 avatar

dave224

Zen Follower

Join Date:
Jun 2012
Posts:
481
Plugin Contributions:
0

Re: Edit Orders v4.0 Support Thread

While trying to find the solution to the incorrect order total in Edit Orders, I found that function eo_update_database_order_totals in admin/includes/functions/extra_functions/edit_orders_functions.php calls function eoGetOrderTotalTax in admin/includes/classes/editOrders.php. For Quantity Discounts, MODULE_ORDER_TOTAL_QUANTITY_DISCOUNT_TAX_CLASS does not exist, so the routine returns zero. This value is subsequently subtracted from $order->info['tax'] and a little later from $order->info['total']. As a test to see if the lack of this ...TAX_CLASS was the source of my problem, I fudged the return from the routine with the tax on the quantity discount. Now when I reran my test case, the order total was correct, but the now the tax was too high by the tax on the discount. I am so confused now I must be missing the obvious. Any help would be gratefully appreciated. I really need to make this work for our store.

14 Feb 2018, 6:39 AM
#1227
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,686
Plugin Contributions:
56

Re: Edit Orders v4.0 Support Thread

I could repro this issue with a Quantity Discount giving 5% off quantities of 5. Start with an order with quantity 4 of an item.

Sub-total: $400
Tax (7%): $28
Total: $428

Run EO and change quantity to 5.
The line items other than the total are correct.

Sub-total: $400
Quantity Discount: $25
Tax (7%): $33.25
Total: $506.50 // should be 508.25

14 Feb 2018, 12:10 PM
#1228
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,067
Plugin Contributions:
56

Re: Edit Orders v4.0 Support Thread

swguy:

I could repro this issue with a Quantity Discount giving 5% off quantities of 5. Start with an order with quantity 4 of an item.

Sub-total: $400
Tax (7%): $28
Total: $428

Run EO and change quantity to 5.
The line items other than the total are correct.

Sub-total: $400
Quantity Discount: $25
Tax (7%): $33.25
Total: $506.50 // should be 508.25
Yep, that's pretty much what I did to replicate the issue. As mentioned above, I've not finding a way for EO to deal with the tax-calculation method that Quantity Discounts applies and there's no method defined to determine the amount of tax an order-total contributed (either via addition or subtraction) to the order.

Whether or not I ticked the "reset totals" box, EO's results were the same.

14 Feb 2018, 12:36 PM
#1229
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,686
Plugin Contributions:
56

Re: Edit Orders v4.0 Support Thread

Does EO work with a built in module like Group Pricing? If so, what's different?

14 Feb 2018, 12:54 PM
#1230
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,067
Plugin Contributions:
56

Re: Edit Orders v4.0 Support Thread

swguy:

Does EO work with a built in module like Group Pricing? If so, what's different?
Yes, it does. The difference is that Group Pricing makes changes to the products' prices and the base tax processing does its thing. For Quantity Discounts, the products' prices are left as-is and the deduction (both in product-cost and tax) is calculated after-the-fact.

14 Feb 2018, 12:58 PM
#1231
dave224 avatar

dave224

Zen Follower

Join Date:
Jun 2012
Posts:
481
Plugin Contributions:
0

Re: Edit Orders v4.0 Support Thread

One thing that's different is that group discount has a tax_class, MODULE_ORDER_TOTAL_GROUP_PRICING_TAX_CLASS, while quantity discount does not. EO logic appears to return 0 for a quantity discount, instead of the tax on the quantity discount of the unedited order (I think). See my last post in this thread.

14 Feb 2018, 1:01 PM
#1232
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,686
Plugin Contributions:
56

Re: Edit Orders v4.0 Support Thread

lat9:

Yes, it does. The difference is that Group Pricing makes changes to the products' prices and the base tax processing does its thing. For Quantity Discounts, the products' prices are left as-is and the deduction (both in product-cost and tax) is calculated after-the-fact.

Are you thinking about something else maybe? The built-in Group Pricing module is an order total module just like the Quantity Discounts order total module. It doesn't change prices. It gives you a single line item discount.

14 Feb 2018, 1:03 PM
#1233
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,686
Plugin Contributions:
56

Re: Edit Orders v4.0 Support Thread

Dave224:

One thing that's different is that group discount has a tax_class, MODULE_ORDER_TOTAL_GROUP_PRICING_TAX_CLASS, while quantity discount does not.

Dave, that setting only applies to Credit Note, which is not a supported setting in my mods.

14 Feb 2018, 1:19 PM
#1234
dave224 avatar

dave224

Zen Follower

Join Date:
Jun 2012
Posts:
481
Plugin Contributions:
0

Re: Edit Orders v4.0 Support Thread

I'm just grasping at straws at this point. I hope you two can figure this out!

It would be nice to know what $order->info['total'] and $order->info['tax'] is supposed to include and what is not to be included at the point in EO logic "after adjustments" in the EO debug logs.

14 Feb 2018, 1:32 PM
#1235
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,686
Plugin Contributions:
56

Re: Edit Orders v4.0 Support Thread

Same problem occurs with Group Discounts. Run the order with no discount, add the customer to a discount group, edit the order - the total is wrong.

Group Discount include tax = false, include shipping = false, recalculate tax = standard.

Original Order:
Sub-Total $500
FL Tax 7% 35.00
Total $535.00

Add Group discount of 25%:

Sub-Total $500
Group Discount $125
FL Tax 7% 26.25
Total $392.50

should be $401.25.

14 Feb 2018, 1:54 PM
#1236
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,067
Plugin Contributions:
56

Re: Edit Orders v4.0 Support Thread

swguy:

Are you thinking about something else maybe? The built-in Group Pricing module is an order total module just like the Quantity Discounts order total module. It doesn't change prices. It gives you a single line item discount.
Yep, I was thinking about the built-in quantity discounts' processing.:blush:

14 Feb 2018, 2:01 PM
#1237
dave224 avatar

dave224

Zen Follower

Join Date:
Jun 2012
Posts:
481
Plugin Contributions:
0

Re: Edit Orders v4.0 Support Thread

If I trick function eoGetOrderTotalTax to return the tax on the quantity discount and make it a negative quantity, the order total and order tax is correct. In my test cases, the discount is $5.00 and the tax is 6%, or $0.30. See code below.

        // -----
        // Cycle through the order-totals to see if any are currently taxed.  If so, remove the
        // tax from the current order in preparation for its recalculation.
        //
        foreach ($order->totals as $current_total) {
            if (in_array($current_total['class'], array('ot_subtotal', 'ot_tax', 'ot_shipping', 'ot_total'))) {
                continue;
            }
            $current_total_tax = $eo->eoGetOrderTotalTax($oID, $current_total['class']);
            $current_total_tax = -0.3; // trick out function for test case
            $order->info['tax'] -= $current_total_tax;
        }
14 Feb 2018, 2:30 PM
#1238
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,067
Plugin Contributions:
56

Re: Edit Orders v4.0 Support Thread

Dave224:

If I trick function eoGetOrderTotalTax to return the tax on the quantity discount and make it a negative quantity, the order total and order tax is correct. In my test cases, the discount is $5.00 and the tax is 6%, or $0.30. See code below.

    // -----
    // Cycle through the order-totals to see if any are currently taxed.  If so, remove the
    // tax from the current order in preparation for its recalculation.
    //
    foreach ($order->totals as $current_total) {
        if (in_array($current_total['class'], array('ot_subtotal', 'ot_tax', 'ot_shipping', 'ot_total'))) {
            continue;
        }
        $current_total_tax = $eo->eoGetOrderTotalTax($oID, $current_total['class']);
        $current_total_tax = -0.3; // trick out function for test case
        $order->info['tax'] -= $current_total_tax;
    }
Unfortunately, the keyword there is **trick**; I'm looking for a *reliable *way to regenerate any tax applied by those order-total modules.
14 Feb 2018, 2:43 PM
#1239
dave224 avatar

dave224

Zen Follower

Join Date:
Jun 2012
Posts:
481
Plugin Contributions:
0

Re: Edit Orders v4.0 Support Thread

The "trick" was to demonstrate that the problem is that quantity discounts is not processed properly in function eoGetOrderTotalTax. If MODULE_ORDER_TOTAL_QUANTITY_DISCOUNT_TAX_CLASS were defined, the function would get the tax on the discount from the database, and no trick would be required. I'm trying to be helpful. If I'm not, tell me and I'll go away.

14 Feb 2018, 2:56 PM
#1240
dave224 avatar

dave224

Zen Follower

Join Date:
Jun 2012
Posts:
481
Plugin Contributions:
0

Re: Edit Orders v4.0 Support Thread

Dave224:

The "trick" was to demonstrate that the problem is that quantity discounts is not processed properly in function eoGetOrderTotalTax. If MODULE_ORDER_TOTAL_QUANTITY_DISCOUNT_TAX_CLASS were defined, the function would get the tax on the discount from the database, and no trick would be required. I'm trying to be helpful. If I'm not, tell me and I'll go away.

Should be "...the function would calculate the tax from the discount value in the database, and ...