Пример #1
0
 /**
  * @param OnlineShop_Framework_Pricing_IEnvironment $environment
  *
  * @return boolean
  */
 public function check(OnlineShop_Framework_Pricing_IEnvironment $environment)
 {
     // init
     $productsPool = array();
     // get current product if we have one
     if ($environment->getProduct()) {
         $productsPool[] = $environment->getProduct();
     }
     // products from cart
     if ($environment->getCart()) {
         foreach ($environment->getCart()->getItems() as $item) {
             $productsPool[] = $item->getProduct();
         }
     }
     // test
     foreach ($productsPool as $currentProduct) {
         // check all valid products
         foreach ($this->getProducts() as $product) {
             /* @var OnlineShop_Framework_AbstractProduct $allow */
             $currentProductCheck = $currentProduct;
             while ($currentProductCheck instanceof OnlineShop_Framework_ProductInterfaces_ICheckoutable) {
                 if ($currentProductCheck->getId() === $product->getId()) {
                     return true;
                 }
                 $currentProductCheck = $currentProductCheck->getParent();
             }
         }
     }
     return false;
 }
Пример #2
0
 /**
  * @param OnlineShop_Framework_Pricing_IEnvironment $environment
  *
  * @return boolean
  */
 public function check(OnlineShop_Framework_Pricing_IEnvironment $environment)
 {
     if (!$environment->getCart() || $environment->getProduct() !== null) {
         return false;
     }
     return $environment->getCart()->getPriceCalculator()->getSubTotal()->getAmount() >= $this->getLimit();
 }