Example #1
0
 public function testAddPreventsDuplicates()
 {
     $catalogPromotion = $this->dummyData->getCatalogPromotion();
     $productQuantityDiscount = $this->dummyData->getProductQuantityDiscount();
     $one = new Price();
     $one->addCatalogPromotion($catalogPromotion);
     $one->addProductQuantityDiscount($productQuantityDiscount);
     $two = new Price();
     $two->addCatalogPromotion($catalogPromotion);
     $two->addProductQuantityDiscount($productQuantityDiscount);
     $three = new Price();
     $three->unitPrice = 0;
     $three->origUnitPrice = 0;
     $three->quantityPrice = 0;
     $three->origQuantityPrice = 0;
     $three->addCatalogPromotion($catalogPromotion);
     $three->addProductQuantityDiscount($productQuantityDiscount);
     $this->assertEquals($three, Price::add($one, $two));
 }
Example #2
0
 public function getPrice(PricingInterface $pricing)
 {
     $price = $this->getProduct()->getPrice($pricing, $this->getQuantity());
     foreach ($this->getCartItemOptionProducts() as $cartItemOptionProduct) {
         $optionPrice = $cartItemOptionProduct->getPrice($pricing, $this->getQuantity());
         $price = Price::add($price, $optionPrice);
     }
     foreach ($this->getCartItemOptionValues() as $cartItemOptionValue) {
         $optionPrice = $cartItemOptionValue->getPrice($this->getQuantity());
         $price = Price::add($price, $optionPrice);
     }
     // No price for cartItemTextOptionValues
     return $price;
 }