|
|
@@ -77,6 +77,9 @@ class OrderShopPriceUtils implements OrderShopPriceUtilsInterface |
|
|
|
|
|
|
|
public function getTotalOrderProductsWithReductions(OrderShopInterface $orderShop) |
|
|
|
{ |
|
|
|
foreach ($orderShop->getOrderReductionCarts() as $orderReductionCart) { |
|
|
|
$reductionAmount = $this->amountOrderProductsReductionCart($orderShop,$orderReductionCart); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
@@ -86,38 +89,66 @@ class OrderShopPriceUtils implements OrderShopPriceUtilsInterface |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public function applyOrderProductsReductionCart(OrderShopInterface $order, $withTax = true) |
|
|
|
public function amountOrderProductsReductionCart(OrderShopInterface $order, $orderReductionCart) |
|
|
|
{ |
|
|
|
|
|
|
|
foreach ($order->getOrderReductionCarts() as $orderReductionCart) { |
|
|
|
if($orderReductionCart->getAppliedTo() === ReductionCart::APPLIED_TO_ORDER_PRODUCTS) { |
|
|
|
if ($orderReductionCart->getUnit() == 'percent') { |
|
|
|
|
|
|
|
$priceWithTax = $this->applyReductionPercent( |
|
|
|
$this->getTotalOrderProductsWithTax($order), |
|
|
|
$orderReductionCart->getValue |
|
|
|
if($orderReductionCart->getAppliedTo() === ReductionCart::APPLIED_TO_ORDER_PRODUCTS) { |
|
|
|
if ($orderReductionCart->getUnit() == 'percent') { |
|
|
|
|
|
|
|
$priceWithTax = $this->applyReductionPercent( |
|
|
|
$this->getTotalOrderProductsWithTax($order), |
|
|
|
$orderReductionCart->getValue |
|
|
|
); |
|
|
|
} else if ($orderReductionCart->getUnit() == 'amount') { |
|
|
|
if ($orderReductionCart->getBehaviorTaxRate() == 'tax-excluded') { |
|
|
|
$priceWithTax = $this->applyTax( |
|
|
|
$this->applyReductionAmount( |
|
|
|
$this->getTotalOrderProducts($order), |
|
|
|
$orderReductionCart->getValue() |
|
|
|
), |
|
|
|
$this->getTaxRateAverage($order) |
|
|
|
); |
|
|
|
} else if ($orderReductionCart->getUnit() == 'amount') { |
|
|
|
if ($orderReductionCart->getBehaviorTaxRate() == 'tax-excluded') { |
|
|
|
$priceWithTax = $this->applyTax( |
|
|
|
$this->applyReductionAmount( |
|
|
|
$this->getTotalOrderProducts($order), |
|
|
|
$orderReductionCart->getValue() |
|
|
|
), |
|
|
|
$this->getTaxRateAverage($order) |
|
|
|
} else if ($orderReductionCart->getBehaviorTaxRate() == 'tax-included') { |
|
|
|
$priceWithTax = |
|
|
|
$this->applyReductionAmount( |
|
|
|
$this->getTotalOrderProductsWithTax($order), |
|
|
|
$orderReductionCart->getValue() |
|
|
|
); |
|
|
|
} else if ($orderReductionCart->getBehaviorTaxRate() == 'tax-included') { |
|
|
|
$priceWithTax = |
|
|
|
$this->applyReductionAmount( |
|
|
|
$this->getTotalOrderProductsWithTax($order), |
|
|
|
$orderReductionCart->getValue() |
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public function amountOrderProductsReductionCredit(OrderShopInterface $order, $orderReductionCart) |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
if ($orderReductionCart->getUnit() == 'percent') { |
|
|
|
|
|
|
|
$priceWithTax = $this->applyReductionPercent( |
|
|
|
$this->getTotalOrderProductsWithTax($order), |
|
|
|
$orderReductionCart->getValue |
|
|
|
); |
|
|
|
} else if ($orderReductionCart->getUnit() == 'amount') { |
|
|
|
if ($orderReductionCart->getBehaviorTaxRate() == 'tax-excluded') { |
|
|
|
$priceWithTax = $this->applyTax( |
|
|
|
$this->applyReductionAmount( |
|
|
|
$this->getTotalOrderProducts($order), |
|
|
|
$orderReductionCart->getValue() |
|
|
|
), |
|
|
|
$this->getTaxRateAverage($order) |
|
|
|
); |
|
|
|
} else if ($orderReductionCart->getBehaviorTaxRate() == 'tax-included') { |
|
|
|
$priceWithTax = |
|
|
|
$this->applyReductionAmount( |
|
|
|
$this->getTotalOrderProductsWithTax($order), |
|
|
|
$orderReductionCart->getValue() |
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |