Loading modules/promotion/src/Plugin/Commerce/PromotionOffer/OrderItemPercentageOff.php +15 −3 Original line number Diff line number Diff line Loading @@ -38,15 +38,27 @@ class OrderItemPercentageOff extends OrderItemPromotionOfferBase { return; } // Display-inclusive promotions must first be applied to the unit price. $amount = $adjusted_unit_price->multiply($percentage); $unit_price = $order_item->getUnitPrice(); $amount = $unit_price->multiply($percentage); $amount = $this->rounder->round($amount); $new_unit_price = $order_item->getUnitPrice()->subtract($amount); // Don't reduce the unit price past 0. if ($amount->greaterThan($adjusted_unit_price)) { $amount = $adjusted_unit_price; } $new_unit_price = $unit_price->subtract($amount); $order_item->setUnitPrice($new_unit_price); $adjustment_amount = $amount->multiply($order_item->getQuantity()); } else { $adjustment_amount = $order_item->getTotalPrice()->multiply($percentage); $adjusted_total_price = $order_item->getAdjustedTotalPrice(['promotion']); $adjustment_amount = $adjusted_total_price->multiply($percentage); // Don't reduce the order item total price past zero. if ($adjustment_amount->greaterThan($adjusted_total_price)) { $adjustment_amount = $adjusted_total_price; } } $adjustment_amount = $this->rounder->round($adjustment_amount); Loading Loading
modules/promotion/src/Plugin/Commerce/PromotionOffer/OrderItemPercentageOff.php +15 −3 Original line number Diff line number Diff line Loading @@ -38,15 +38,27 @@ class OrderItemPercentageOff extends OrderItemPromotionOfferBase { return; } // Display-inclusive promotions must first be applied to the unit price. $amount = $adjusted_unit_price->multiply($percentage); $unit_price = $order_item->getUnitPrice(); $amount = $unit_price->multiply($percentage); $amount = $this->rounder->round($amount); $new_unit_price = $order_item->getUnitPrice()->subtract($amount); // Don't reduce the unit price past 0. if ($amount->greaterThan($adjusted_unit_price)) { $amount = $adjusted_unit_price; } $new_unit_price = $unit_price->subtract($amount); $order_item->setUnitPrice($new_unit_price); $adjustment_amount = $amount->multiply($order_item->getQuantity()); } else { $adjustment_amount = $order_item->getTotalPrice()->multiply($percentage); $adjusted_total_price = $order_item->getAdjustedTotalPrice(['promotion']); $adjustment_amount = $adjusted_total_price->multiply($percentage); // Don't reduce the order item total price past zero. if ($adjustment_amount->greaterThan($adjusted_total_price)) { $adjustment_amount = $adjusted_total_price; } } $adjustment_amount = $this->rounder->round($adjustment_amount); Loading