/** * Callback for add_to_cart button * * @param IsotopeProduct $objProduct * @param array $arrConfig */ public function addToCart(IsotopeProduct $objProduct, array $arrConfig = array()) { $objModule = $arrConfig['module']; $intQuantity = $objModule->iso_use_quantity && intval(\Input::post('quantity_requested')) > 0 ? intval(\Input::post('quantity_requested')) : 1; // Do not add parent of variant product to the cart if ($objProduct->hasVariants() && !$objProduct->isVariant()) { return; } if (Isotope::getCart()->addProduct($objProduct, $intQuantity, $arrConfig) !== false) { Message::addConfirmation($GLOBALS['TL_LANG']['MSC']['addedToCart']); if (!$objModule->iso_addProductJumpTo) { $this->reload(); } \Controller::redirect(\Haste\Util\Url::addQueryString('continue=' . base64_encode(\Environment::get('request')), $objModule->iso_addProductJumpTo)); } }
/** * 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(); } }