저자: Hugo Briand (briand@ekino.com)
예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function calculatePrice(ProductInterface $product, CurrencyInterface $currency, $vat = false, $quantity = 1)
 {
     if (!is_int($quantity) || $quantity < 1) {
         throw new InvalidParameterException("Expected integer >= 1 for quantity, " . $quantity . " given.");
     }
     return floatval(bcmul($this->currencyPriceCalculator->getPrice($product, $currency, $vat), $quantity));
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function calculatePrice(ProductInterface $product, CurrencyInterface $currency, $vat = false, $quantity = 1)
 {
     $event = new BeforeCalculatePriceEvent($product, $currency, $vat, $quantity);
     $this->getEventDispatcher()->dispatch(BasketEvents::PRE_CALCULATE_PRICE, $event);
     $vat = $event->getVat();
     $quantity = $event->getQuantity();
     if (!is_int($quantity) || $quantity < 1) {
         throw new InvalidParameterException("Expected integer >= 1 for quantity, " . $quantity . " given.");
     }
     $price = floatval(bcmul($this->currencyPriceCalculator->getPrice($product, $currency, $vat), $quantity));
     $afterEvent = new AfterCalculatePriceEvent($product, $currency, $vat, $quantity, $price);
     $this->getEventDispatcher()->dispatch(BasketEvents::POST_CALCULATE_PRICE, $afterEvent);
     return $afterEvent->getPrice();
 }