Пример #1
0
 /**
  * Checks for the product limits when the configuration contains limits per currency.
  *
  * @param \Aimeos\MShop\Order\Item\Base\Iface $order Basket object
  * @param \Aimeos\MShop\Order\Item\Base\Product\Iface $value Order product item
  * @throws \Aimeos\MShop\Plugin\Provider\Exception If one limit is exceeded
  */
 protected function checkWithCurrency(\Aimeos\MShop\Order\Item\Base\Iface $order, \Aimeos\MShop\Order\Item\Base\Product\Iface $value)
 {
     $config = $this->getItemBase()->getConfig();
     $currencyId = $value->getPrice()->getCurrencyId();
     if (isset($config['single-value-max'][$currencyId]) && $value->getPrice()->getValue() * $value->getQuantity() > (double) $config['single-value-max'][$currencyId]) {
         $msg = $this->getContext()->getI18n()->dt('mshop', 'The maximum product value is %1$s');
         throw new \Aimeos\MShop\Plugin\Provider\Exception(sprintf($msg, $config['single-value-max'][$currencyId]));
     }
     if (isset($config['total-value-max'][$currencyId])) {
         $price = clone $value->getPrice();
         $price->setValue($price->getValue() * $value->getQuantity());
         foreach ($order->getProducts() as $product) {
             $price->addItem($product->getPrice(), $product->getQuantity());
         }
         if ((double) $price->getValue() > (double) $config['total-value-max'][$currencyId]) {
             $msg = $this->getContext()->getI18n()->dt('mshop', 'The maximum value of all products is %1$s');
             throw new \Aimeos\MShop\Plugin\Provider\Exception(sprintf($msg, $config['total-value-max'][$currencyId]));
         }
     }
 }
Пример #2
0
 /**
  * Compares the properties of the given order product item with its own ones.
  *
  * @param \Aimeos\MShop\Order\Item\Base\Product\Iface $item Order product item
  * @return boolean True if the item properties are equal, false if not
  * @since 2014.09
  */
 public function compare(\Aimeos\MShop\Order\Item\Base\Product\Iface $item)
 {
     if ($this->getFlags() === $item->getFlags() && $this->getName() === $item->getName() && $this->getProductCode() === $item->getProductCode() && $this->getSupplierCode() === $item->getSupplierCode() && $this->getPrice()->compare($item->getPrice()) === true) {
         return true;
     }
     return false;
 }