Closed helgatheviking closed 1 year ago
B/c this is actually something related to WC core... (a coupon is not applied to a new line item) -- but technically we're replacing the same line item (though done by removing and re-adding) we might need to account for it here: https://github.com/kathyisawesome/woocommerce-mix-and-match-products/blob/2.4.0-dev/includes/class-wc-mnm-ajax.php#L131
Subscription editing does that here: https://github.com/kathyisawesome/wc-mnm-subscription-editing/blob/trunk/wc-mnm-subscription-editing.php#L329
Maybe that should come out of the subscription editing plugin and go back to MNM core?
apply coupon in the admin traces back to : https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/src/Internal/Orders/CouponsController.php#L47
but $order->apply_coupon()
might count the coupon as being used again which wouldn't be correct
https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/includes/abstracts/abstract-wc-order.php#L1240-L1244
$order->recalculate_coupons();
might be enough!
closed by 5f7d634bf3f855d5ca26f309b081291fedb9fb71
traced this back to WooCommerce core. Once you apply a coupon, if you add new items to the order, the coupon does not automatically apply to then. And when in the admin (actually in the front end too) the mix and match line items are removed and ones with the new configuration are added. And since Woo doesn't apply coupons after the fact, the discounts get lost. I'll have to mull that one over a bit because it's complicated and again, apparently that's how Woo works (to my surprise)