Exemple #1
0
 /**
  * Go to cart view if cart is empty
  *
  * @return void
  */
 public function handleRequest()
 {
     if (!$this->getCart()->checkCart()) {
         $this->setHardRedirect();
         $this->setReturnURL($this->buildURL('cart'));
     }
     parent::handleRequest();
 }
Exemple #2
0
 /**
  * Handles the request.
  * Parses the request variables if necessary. Attempts to call the specified action function
  *
  * @return void
  */
 public function handleRequest()
 {
     if (\XLite\Core\Config::getInstance()->CDev->Catalog->disable_checkout) {
         $this->redirect($this->buildUrl(\XLite::TARGET_DEFAULT));
     } else {
         parent::handleRequest();
     }
 }
Exemple #3
0
 /**
  * Correct product amount to add to cart.
  *
  * @param \XLite\Model\Product $product Product to add
  * @param integer|null         $amount  Amount of product
  *
  * @return integer
  */
 protected function correctAmountAsProduct(\XLite\Model\Product $product, $amount)
 {
     if (is_null($amount) && $product->mustHaveVariants()) {
         $amount = 1;
     } else {
         $amount = parent::correctAmountAsProduct($product, $amount);
     }
     return $amount;
 }
Exemple #4
0
 /**
  * URL to return after product is added
  *
  * @return string
  */
 protected function setURLToReturn()
 {
     if (\XLite\Core\Request::getInstance()->expressCheckout) {
         $params = array('cancelUrl' => \XLite\Core\Request::getInstance()->cancelUrl);
         if (\XLite\Core\Request::getInstance()->inContext) {
             $params['inContext'] = true;
         }
         $this->setReturnURL($this->buildURL('checkout', 'start_express_checkout', $params));
     } else {
         parent::setURLToReturn();
     }
 }
Exemple #5
0
 /**
  * URL to return after product is added
  *
  * @return string
  */
 protected function setURLToReturn()
 {
     if (\XLite\Core\Request::getInstance()->expressCheckout) {
         $params = array('cancelUrl' => \XLite\Core\Request::getInstance()->cancelUrl);
         if (\XLite\Core\Request::getInstance()->inContext) {
             $params['inContext'] = true;
         }
         $url = \XLite::getInstance()->getShopURL($this->buildURL('checkout', 'start_express_checkout', $params), \XLite\Core\Config::getInstance()->Security->customer_security);
         $this->setReturnURL($url);
     } else {
         parent::setURLToReturn();
     }
 }
Exemple #6
0
 /**
  * Check if current page is accessible
  *
  * @return boolean
  */
 protected function checkAccess()
 {
     return parent::checkAccess() && $this->getCart()->getOrigProfile() && !$this->getCart()->getOrigProfile()->getOrder();
 }
 /**
  * Define the account links availability
  *
  * @return boolean
  */
 public function isAccountLinksVisible()
 {
     return parent::isAccountLinksVisible() && $this->isCheckoutAvailable();
 }
Exemple #8
0
 /**
  * Check if the requested amount is available for the product
  *
  * @param \XLite\Model\OrderItem $item   Order item to add
  * @param integer                $amount Amount to check OPTIONAL
  *
  * @return integer
  */
 protected function checkAmount(\XLite\Model\OrderItem $item, $amount = null)
 {
     return $item->getVariant() && !$item->getVariant()->getDefaultAmount() ? ($amount ?: 0) < $item->getVariant()->getAvailableAmount() : parent::checkAmount($item, $amount);
 }
Exemple #9
0
 /**
  * Disable redirect to cart after 'Add-to-cart' action
  *
  * @return void
  */
 protected function setURLToReturn()
 {
     \XLite\Core\Config::getInstance()->General->redirect_to_cart = false;
     parent::setURLToReturn();
 }
Exemple #10
0
 /**
  * Check if current page is accessible
  *
  * @return boolean
  */
 protected function checkAccess()
 {
     return parent::checkAccess() && \XLite\Core\Auth::getInstance()->isLogged();
 }
Exemple #11
0
 /**
  * 'add' action
  *
  * @return void
  */
 protected function doActionAdd()
 {
     parent::doActionAdd();
     // check for valid ProductOptions
     if ($this->optionInvalid) {
         // Save wrong options set
         $request = \XLite\Core\Request::getInstance();
         \XLite\Core\Session::getInstance()->saved_invalid_options = array($request->product_id => $request->product_options);
         \XLite\Core\TopMessage::getInstance()->clear();
         \XLite\Core\TopMessage::addError('The product options you have selected are not valid or fall into an exception.' . ' Please select other product options and add the product to cart once again.');
         $this->setReturnURL($this->buildURL('product', '', array('product_id' => \XLite\Core\Request::getInstance()->product_id)));
     } else {
         \XLite\Core\Session::getInstance()->saved_invalid_options = null;
     }
 }