/** * Checks for the product limits when the configuration contains limits per currency. * * @param MShop_Order_Item_Base_Interface $order Basket object * @param MShop_Order_Item_Base_Product_Interface $value Order product item * @throws MShop_Plugin_Provider_Exception If one limit is exceeded */ protected function _checkWithCurrency(MShop_Order_Item_Base_Interface $order, MShop_Order_Item_Base_Product_Interface $value) { $config = $this->_getItem()->getConfig(); $currencyId = $value->getPrice()->getCurrencyId(); if (isset($config['single-value-max'][$currencyId]) && $value->getPrice()->getValue() * $value->getQuantity() > (double) $config['single-value-max'][$currencyId]) { $msg = sprintf('The maximum product value is %1$s', $config['single-value-max'][$currencyId]); throw new MShop_Plugin_Provider_Exception($msg); } 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 = sprintf('The maximum value of all products is %1$s', $config['total-value-max'][$currencyId]); throw new MShop_Plugin_Provider_Exception($msg); } } }
/** * Compares the properties of the given order product item with its own ones. * * @param MShop_Order_Item_Base_Product_Interface $item Order product item * @return boolean True if the item properties are equal, false if not * @since 2014.09 */ public function compare(MShop_Order_Item_Base_Product_Interface $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; }