This is a post-RC1 task.

Right now OrderPercentageOff just adds an order-level adjustment.
Instead, we should add an adjustment to each order item + an order-level adjustment for the rest (such as shipping costs. We achieve the same numbers, but optimize for better refunds, cause the order item's adjusted price will now be more precise (showing the applied promotion).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bojanz created an issue. See original summary.

smccabe’s picture

Would this also allow us to do stuff like not discount shipping but discount the order, or would that be an additional issue? With this change it would just be a simple config toggle?

mglaman’s picture

Assigned: Unassigned » mglaman

We need this for our implementation. We need to pass the adjusted unit price to a remote service which does its own quantity multiplication.

mglaman’s picture

Assigned: mglaman » Unassigned
Status: Active » Needs review
FileSize
1.63 KB

Patch, will make PR later.

mglaman’s picture

Title: OrderPercentageOff should reduce each order item / adjustment » Order offers should reduce each order item / adjustment
Status: Needs review » Needs work

We should also fix order_fixed_amount_off

bojanz’s picture

We need to add promotion adjustments for any positive order adjustments as well.
If the order has a $20 shipping cost, then that needs to be reduced too for the order total to be correct, same for fees.

MegaChriz’s picture

Adding related issues.

#2896066: Allow the OrderPercentageOff offer to reduce shipping costs and other adjustments is related because of the comment in #2.
#2897190: Tax calculations do not take discounts (promotions) into account is related because I think that an order based discount should be divided per ratio over the individual order items. The reason for this is to be able to calculate taxes based on the product price inclusive discount.

swickham’s picture

Assigned: Unassigned » swickham

I can get at this over the weekend.

swickham’s picture

Here's what I have so far but it's not complete. The issue:

Discounts to items like shipping need to be applied to the order itself since adjustments can't have adjustments applied to them like order items can. This causes an issue when calculating percentage discounts since the percentage needs to be based off their discounted value otherwise you end up with too high of a discount, assuming the percentage should come off their adjusted amount.

I can either use the same kind of calculations like I did in the OrderFixedAmountOff plugin to make sure the discounts on the order are applied evenly amongst the items but that's starting to feel sloppy.

Should we consider making it so adjustments can have adjustments applied to them?

bojanz’s picture

Title: Order offers should reduce each order item / adjustment » Order offers should reduce each order item

Note that order promotions now apply to the subtotal, excluding shipping and other adjustments: #2926559: Apply order promotions to the subtotal, not the total.

That should make this issue easer to achieve. Matt's percentage part already looks good, we just need to work on the fixed one.

swickham’s picture

Assigned: swickham » Unassigned
edurenye’s picture

Status: Needs work » Needs review
FileSize
9.06 KB

Just rerolled, I didn't tested it yet.

Status: Needs review » Needs work

The last submitted patch, 12: order_offers_should-2865701-12.patch, failed testing. View results

bojanz’s picture

Title: Order offers should reduce each order item » Percentage order offers should reduce each order item
Issue tags: +ny-bogo

Let's split this up and get it in.
Opened #2980195: Fixed order offers should reduce each order item for the fixed offers, and we'll do percentage offers here.

  • bojanz committed 0855a14 on 8.x-2.x
    Issue #2865701 by swickham, mglaman, edurenye, bojanz: Percentage order...
bojanz’s picture

Priority: Normal » Major
Status: Needs work » Fixed

Had to completely rebuild the patch, the underlying code changed too much.

Thanks, everyone! See you in #2980195: Fixed order offers should reduce each order item.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.