示例#1
0
 private function calculateCartPriceRules()
 {
     foreach ($this->pricing->getCartPriceRules() as $cartPriceRule) {
         if ($cartPriceRule->isValid($this->pricing->getDate(), $this->cart->getCartItems())) {
             $numberTimesToApply = $cartPriceRule->numberTimesToApply($this->cart->getCartItems());
             foreach ($cartPriceRule->getCartPriceRuleDiscounts() as $discount) {
                 $price = $this->pricing->getPrice($discount->getProduct(), $discount->getQuantity());
                 $discountValue = $price->quantityPrice;
                 $discountValue *= $numberTimesToApply;
                 $this->cartTotal->discount += $discountValue;
                 if ($cartPriceRule->getReducesTaxSubtotal() and $discount->getProduct()->isTaxable()) {
                     $this->cartTotal->taxSubtotal -= $discountValue;
                 }
                 $this->cartTotal->addCartPriceRule($cartPriceRule);
             }
         }
     }
     // No subtotal below zero!
     $this->cartTotal->subtotal = max(0, $this->cartTotal->subtotal);
 }
示例#2
0
 public function testCreateWithEmptyDate()
 {
     $price = $this->pricing->getPrice(new Product(), 1);
     $this->assertTrue($price instanceof Price);
 }