Commit 08a1e6ad authored by Jonathan Sacksick's avatar Jonathan Sacksick Committed by Jonathan Sacksick
Browse files

Issue #3268581 by jsacksick, gge: Wrong price and order subtotal calculation...

Issue #3268581 by jsacksick, gge: Wrong price and order subtotal calculation when using a promotion + a promotion with coupons.
parent 43dbce5c
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -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);