- 🇺🇦Ukraine init90 Ukraine
I encounter the issue when adding a discount to the product for which the price can be adjusted by the customer based on the selected options. In the order item we tell that the price is overridden, i.e. 'overridden_unit_price' set to TRUE. This means that on refresh order item price won't be updated according to the product variation price.
With the standard setup, I had 2 issues:
1. It lost the 'overridden_unit_price' setting which lead to the loss customization price.
2. It's updated already updated order item price, which leads to incorrect calculation.As a workaround, I created a custom promotion plugin that fixes the problems above.
To fix first point the plugin account 'overridden_unit_price' setting:
$order_item->setUnitPrice($new_unit_price, $order_item->isUnitPriceOverridden());
To resolve the second point passes the original price to the order item
$order_item->setData('original_price', $price);
in add to cart event. Then in the promotion plugin discount always applies to the original price.Hope at some time the issue will be fixed with the solution like in message #16.
As #18, i have custom price and need to override unit price when product is adding to cart
unfortunately, promotion with display_inclusive lost the overriden unit price boolean field
i found make it works updating promotion class and get overriden unit price field to keep it when apply promotion
- 🇮🇱Israel jsacksick
I don't think the patch from #19 is the correct fix. This will cause the discounted price to be the new overridden unit price, so the price will keep reducing on each refresh.
What we need instead is anunprocessed_unit_price
field I guess?But I guess the question is how do we actually restore the overridden unit price on each refresh? I'd say it is the responsability of an order processor that runs early to constantly set the right unit price?