Esempio n. 1
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();
 }
Esempio n. 2
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;
 }
Esempio n. 3
0
 /**
  * @param OnlineShop_Framework_Pricing_IEnvironment $environment
  *
  * @return OnlineShop_Framework_Pricing_IAction
  */
 public function executeOnProduct(OnlineShop_Framework_Pricing_IEnvironment $environment)
 {
     $priceinfo = $environment->getPriceInfo();
     $amount = $this->getAmount() !== 0 ? $this->getAmount() : $priceinfo->getAmount() * ($this->getPercent() / 100);
     $amount = $priceinfo->getAmount() - $amount;
     $priceinfo->setAmount($amount > 0 ? $amount : 0);
     return $this;
 }
Esempio n. 4
0
 /**
  * @param OnlineShop_Framework_Pricing_IEnvironment $environment
  *
  * @return OnlineShop_Framework_Pricing_IAction
  */
 public function executeOnCart(OnlineShop_Framework_Pricing_IEnvironment $environment)
 {
     $priceCalculator = $environment->getCart()->getPriceCalculator();
     $modDiscount = new OnlineShop_Framework_Impl_CartPriceModificator_Discount($environment->getRule());
     $amount = round($this->getAmount() !== 0 ? $this->getAmount() : $priceCalculator->getSubTotal()->getAmount() * ($this->getPercent() / 100), 2);
     $modDiscount->setAmount('-' . $amount);
     $priceCalculator->addModificator($modDiscount);
     return $this;
 }
Esempio n. 5
0
 /**
  * @param OnlineShop_Framework_Pricing_IEnvironment $environment
  *
  * @return boolean
  */
 public function check(OnlineShop_Framework_Pricing_IEnvironment $environment)
 {
     $rule = $environment->getRule();
     if ($rule) {
         return $this->getSalesAmount($rule) < $this->getAmount();
     } else {
         return false;
     }
 }
Esempio n. 6
0
 /**
  * @param OnlineShop_Framework_Pricing_IEnvironment $environment
  *
  * @return OnlineShop_Framework_Pricing_IAction
  */
 public function executeOnCart(OnlineShop_Framework_Pricing_IEnvironment $environment)
 {
     $priceCalculator = $environment->getCart()->getPriceCalculator();
     $list = $priceCalculator->getModificators();
     foreach ($list as &$modificator) {
         /* @var OnlineShop_Framework_ICartPriceModificator $modificator_ */
         // remove shipping charge
         if ($modificator instanceof OnlineShop_Framework_CartPriceModificator_IShipping) {
             $modificator->setCharge(0);
             $priceCalculator->reset();
         }
     }
     return $this;
 }
Esempio n. 7
0
 /**
  * @param OnlineShop_Framework_Pricing_IEnvironment $environment
  *
  * @return boolean
  */
 public function check(OnlineShop_Framework_Pricing_IEnvironment $environment)
 {
     if (!($cart = $environment->getCart())) {
         return false;
     }
     $voucherTokenCodes = $cart->getVoucherTokenCodes();
     if (is_array($voucherTokenCodes)) {
         foreach ($voucherTokenCodes as $code) {
             if (in_array(OnlineShop_Framework_VoucherService_Token::getByCode($code)->getVoucherSeriesId(), $this->whiteListIds)) {
                 return true;
             }
         }
     }
     return false;
 }
Esempio n. 8
0
 /**
  * @param OnlineShop_Framework_Pricing_IEnvironment $environment
  *
  * @return OnlineShop_Framework_Pricing_Action_IGift
  */
 public function executeOnCart(OnlineShop_Framework_Pricing_IEnvironment $environment)
 {
     $comment = $environment->getRule()->getDescription();
     $environment->getCart()->addGiftItem($this->getProduct(), 1, null, true, array(), array(), $comment);
 }
Esempio n. 9
0
 /**
  * @param OnlineShop_Framework_Pricing_IEnvironment $environment
  *
  * @return boolean
  */
 public function check(OnlineShop_Framework_Pricing_IEnvironment $environment)
 {
     foreach ($environment->getCategories() as $category) {
         /* @var OnlineShop_Framework_AbstractCategory $category */
         foreach ($this->getCategories() as $allow) {
             /* @var OnlineShop_Framework_AbstractCategory $allow */
             if (strpos($category->getFullPath(), $allow->getFullPath()) !== false) {
                 return true;
             }
         }
     }
     return false;
 }
Esempio n. 10
0
 /**
  * @param OnlineShop_Framework_Pricing_IEnvironment $environment
  *
  * @return boolean
  */
 public function check(OnlineShop_Framework_Pricing_IEnvironment $environment)
 {
     $token = $environment->getSession()->token;
     return $token === $this->getToken();
 }