Example #1
0
 /**
  * Checks for requirements.
  *
  * @param \Aimeos\MShop\Order\Item\Base\Iface $base Basic order of the customer
  * @return boolean True if the requirements are met, false if not
  */
 public function isAvailable(\Aimeos\MShop\Order\Item\Base\Iface $base)
 {
     if (($prodcode = $this->getConfigValue('required.productcode')) !== null) {
         foreach ($base->getProducts() as $product) {
             if ($product->getProductCode() == $prodcode) {
                 return parent::isAvailable($base);
             }
         }
         return false;
     }
     return true;
 }
Example #2
0
 /**
  * Checks for the min/max order value.
  *
  * @param \Aimeos\MShop\Order\Item\Base\Iface $base Basic order of the customer
  * @return boolean True if the basket matches the constraints, false if not
  */
 public function isAvailable(\Aimeos\MShop\Order\Item\Base\Iface $base)
 {
     $price = $base->getPrice();
     $currency = $price->getCurrencyId();
     $value = $price->getValue() + $price->getRebate();
     $minvalue = $this->getConfigValue('basketvalues.total-value-min', array());
     if (isset($minvalue[$currency]) && $minvalue[$currency] > $value) {
         return false;
     }
     $maxvalue = $this->getConfigValue('basketvalues.total-value-max', array());
     if (isset($maxvalue[$currency]) && $maxvalue[$currency] < $value) {
         return false;
     }
     return parent::isAvailable($base);
 }