コード例 #1
0
ファイル: Discount.php プロジェクト: spryker/Discount
 /**
  * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer
  * @param \Generated\Shared\Transfer\CollectedDiscountTransfer[] $collectedDiscounts
  *
  * @return void
  */
 protected function addDiscountsToQuote(QuoteTransfer $quoteTransfer, array $collectedDiscounts)
 {
     $quoteTransfer->setVoucherDiscounts(new \ArrayObject());
     $quoteTransfer->setCartRuleDiscounts(new \ArrayObject());
     foreach ($collectedDiscounts as $collectedDiscountTransfer) {
         $discountTransfer = $collectedDiscountTransfer->getDiscount();
         if ($discountTransfer->getVoucherCode()) {
             $quoteTransfer->addVoucherDiscount($discountTransfer);
         } else {
             $quoteTransfer->addCartRuleDiscount($discountTransfer);
         }
     }
 }