コード例 #1
0
ファイル: Module.php プロジェクト: rpquadrat/core
 /**
  * Include messages if enabled
  *
  * @return string
  */
 public function generate()
 {
     $strBuffer = parent::generate();
     // Prepend any messages to the module output
     if ($this->iso_includeMessages) {
         $strBuffer = Message::generate() . $strBuffer;
     }
     return $strBuffer;
 }
コード例 #2
0
ファイル: Rules.php プロジェクト: bytehead/core
 /**
  * Callback for checkout Hook. Transfer active rules to usage table.
  */
 public function writeRuleUsages($objOrder)
 {
     $objCart = Cart::findByPk($objOrder->source_collection_id);
     $objRules = Rule::findActiveWitoutCoupons();
     $arrRules = null === $objRules ? array() : $objRules->fetchEach('id');
     $arrCoupons = deserialize($objCart->coupons);
     if (is_array($arrCoupons) && !empty($arrCoupons)) {
         $blnError = false;
         foreach ($arrCoupons as $k => $code) {
             $objRule = Rule::findOneByCouponCode($code, $objCart->getItems());
             if (null === $objRule) {
                 Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['couponCodeDropped'], $code));
                 unset($arrCoupons[$k]);
                 $blnError = true;
             } else {
                 $arrRules[] = $objRule->id;
             }
         }
         if ($blnError) {
             $objCart->coupons = $arrCoupons;
             return false;
         }
     }
     if (!empty($arrRules)) {
         $time = time();
         \Database::getInstance()->query("INSERT INTO tl_iso_rule_usage (pid,tstamp,order_id,config_id,member_id) VALUES (" . implode(", {$time}, {$objOrder->id}, " . (int) Isotope::getConfig()->id . ", {$objOrder->member}), (", $arrRules) . ", {$time}, {$objOrder->id}, " . (int) Isotope::getConfig()->id . ", {$objOrder->member})");
     }
     return true;
 }
コード例 #3
0
ファイル: Frontend.php プロジェクト: bytehead/core
 /**
  * Return all error, confirmation and info messages as HTML string
  *
  * @return string
  *
  * @deprecated use Isotope\Message::generate
  */
 public static function getIsotopeMessages()
 {
     return Message::generate();
 }
コード例 #4
0
 /**
  * @category ISO_HOOKS: preCheckout
  *
  * @param ProductCollection\Order $order
  * @param Checkout                $checkout
  *
  * @return bool
  */
 public function checkBeforeCheckout(ProductCollection\Order $order, Checkout $checkout)
 {
     foreach ($order->getItems() as $item) {
         /** @var Product|\Model $product */
         $product = $item->getProduct();
         $productType = $product->getRelated('type');
         $stock = Stock::getStockForProduct($product->id);
         if ($productType->stockmanagement_active && false !== $stock && $item->quantity > $stock) {
             Message::addError($GLOBALS['TL_LANG']['MSC']['simpleStockmanagement']['productQuantityUnavailable']);
             if ($checkout->iso_cart_jumpTo > 0) {
                 /** @type \PageModel $jumpTo */
                 $jumpTo = \PageModel::findPublishedById($checkout->iso_cart_jumpTo);
                 if (null !== $jumpTo) {
                     $jumpTo->loadDetails();
                     \Controller::redirect($jumpTo->getFrontendUrl(null, $jumpTo->language));
                 }
             }
             return false;
         }
     }
     return true;
 }
コード例 #5
0
ファイル: Cart.php プロジェクト: ralfhartmann/isotope_core
 /**
  * Merge guest cart if necessary
  */
 public function mergeGuestCart()
 {
     $this->ensureNotLocked();
     $strHash = \Input::cookie(static::$strCookie);
     // Temporary cart available, move to this cart. Must be after creating a new cart!
     if (FE_USER_LOGGED_IN === true && $strHash != '' && $this->member > 0) {
         $blnMerge = $this->countItems() > 0 ? true : false;
         $objTemp = static::findOneBy(array('uniqid=?', 'store_id=?'), array($strHash, $this->store_id));
         if (null !== $objTemp) {
             $arrIds = $this->copyItemsFrom($objTemp);
             if ($blnMerge && !empty($arrIds)) {
                 Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['cartMerged']);
             }
             $objTemp->delete();
         }
         // Delete cookie
         \System::setCookie(static::$strCookie, '', time() - 3600, $GLOBALS['TL_CONFIG']['websitePath']);
         \Controller::reload();
     }
 }
コード例 #6
0
 /**
  * Update product collection item with given ID
  *
  * @param int   $intId
  * @param array $arrSet
  *
  * @return bool
  */
 public function updateItemById($intId, $arrSet)
 {
     $this->ensureNotLocked();
     $arrItems = $this->getItems();
     if (!isset($arrItems[$intId])) {
         return false;
     }
     /** @var ProductCollectionItem $objItem */
     $objItem = $arrItems[$intId];
     // !HOOK: additional functionality when updating a product in the collection
     if (isset($GLOBALS['ISO_HOOKS']['updateItemInCollection']) && is_array($GLOBALS['ISO_HOOKS']['updateItemInCollection'])) {
         foreach ($GLOBALS['ISO_HOOKS']['updateItemInCollection'] as $callback) {
             $objCallback = \System::importStatic($callback[0]);
             $arrSet = $objCallback->{$callback}[1]($objItem, $arrSet, $this);
             if (empty($arrSet) && is_array($arrSet)) {
                 return false;
             }
         }
     }
     // Quantity set to 0, delete item
     if (isset($arrSet['quantity']) && $arrSet['quantity'] == 0) {
         return $this->deleteItemById($intId);
     }
     if (isset($arrSet['quantity']) && $objItem->hasProduct()) {
         // Set product quantity so we can determine the correct minimum price
         $objProduct = $objItem->getProduct();
         $intMinimumQuantity = $objProduct->getMinimumQuantity();
         if ($arrSet['quantity'] < $intMinimumQuantity) {
             Message::addInfo(sprintf($GLOBALS['TL_LANG']['ERR']['productMinimumQuantity'], $objProduct->name, $intMinimumQuantity));
             $arrSet['quantity'] = $intMinimumQuantity;
         }
     }
     $arrSet['tstamp'] = time();
     foreach ($arrSet as $k => $v) {
         $objItem->{$k} = $v;
     }
     $objItem->save();
     $this->tstamp = time();
     // !HOOK: additional functionality when adding product to collection
     if (isset($GLOBALS['ISO_HOOKS']['postUpdateItemInCollection']) && is_array($GLOBALS['ISO_HOOKS']['postUpdateItemInCollection'])) {
         foreach ($GLOBALS['ISO_HOOKS']['postUpdateItemInCollection'] as $callback) {
             $objCallback = \System::importStatic($callback[0]);
             $objCallback->{$callback}[1]($objItem, $arrSet['quantity'], $this);
         }
     }
     return true;
 }
コード例 #7
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     $this->Template->messages = Message::getAll();
 }