/** * Sets the necessary parameter values in the view. */ public function process() { $view = $this->getView(); $context = $this->getContext(); try { $options = array('stock' => $view->config('client/html/basket/require-stock', true), 'variant' => $view->config('client/html/basket/require-variant', true)); switch ($view->param('b_action')) { case 'add': $this->addProducts($view, $options); break; case 'delete': $this->deleteProducts($view); break; default: $this->editProducts($view, $options); } parent::process(); $controller = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket'); $controller->get()->check(\Aimeos\MShop\Order\Item\Base\Base::PARTS_PRODUCT); } catch (\Aimeos\Client\Html\Exception $e) { $error = array($context->getI18n()->dt('client', $e->getMessage())); $view->standardErrorList = $view->get('standardErrorList', array()) + $error; } catch (\Aimeos\Controller\Frontend\Exception $e) { $error = array($context->getI18n()->dt('controller/frontend', $e->getMessage())); $view->standardErrorList = $view->get('standardErrorList', array()) + $error; } catch (\Aimeos\MShop\Plugin\Provider\Exception $e) { $errors = array($context->getI18n()->dt('mshop', $e->getMessage())); $errors = array_merge($errors, $this->translatePluginErrorCodes($e->getErrorCodes())); $view->summaryErrorCodes = $e->getErrorCodes(); $view->standardErrorList = $view->get('standardErrorList', array()) + $errors; } catch (\Aimeos\MShop\Exception $e) { $error = array($context->getI18n()->dt('mshop', $e->getMessage())); $view->standardErrorList = $view->get('standardErrorList', array()) + $error; } catch (\Exception $e) { $context->getLogger()->log($e->getMessage() . PHP_EOL . $e->getTraceAsString()); $error = array($context->getI18n()->dt('client', 'A non-recoverable error occured')); $view->standardErrorList = $view->get('standardErrorList', array()) + $error; } }
/** * Processes the input, e.g. store given values. * A view must be available and this method doesn't generate any output * besides setting view variables. */ public function process() { $view = $this->getView(); $context = $this->getContext(); switch ($view->param('b_action')) { case 'coupon-delete': if (($coupon = $view->param('b_coupon')) != '') { $this->clearCached(); $cntl = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket'); $cntl->deleteCoupon($coupon); } break; default: if (($coupon = $view->param('b_coupon')) != '') { $this->clearCached(); $cntl = \Aimeos\Controller\Frontend\Factory::createController($context, 'basket'); /** client/html/basket/standard/coupon/allowed * Number of coupon codes a customer is allowed to enter * * This configuration option enables shop owners to limit the number of coupon * codes that can be added by a customer to his current basket. By default, only * one coupon code is allowed per order. * * Coupon codes are valid until a payed order is placed by the customer. The * "count" of the codes is decreased afterwards. If codes are not personalized * the codes can be reused in the next order until their "count" reaches zero. * * @param integer Positive number of coupon codes including zero * @since 2014.05 * @category User * @category Developer */ $allowed = $context->getConfig()->get('client/html/basket/standard/coupon/allowed', 1); if ($allowed <= count($cntl->get()->getCoupons())) { throw new \Aimeos\Client\Html\Exception(sprintf('Number of coupon codes exceeds the limit')); } $cntl->addCoupon($coupon); } break; } parent::process(); }
/** * Sets the necessary parameter values in the view. */ public function process() { $view = $this->getView(); $context = $this->getContext(); $controller = $this->getController(); try { $options = array('stock' => $view->config('client/html/basket/require-stock', true), 'variant' => $view->config('client/html/basket/require-variant', true)); switch ($view->param('b_action')) { case 'add': $this->addProducts($view, $options); break; case 'coupon-delete': $this->deleteCoupon($view); break; case 'delete': $this->deleteProducts($view); break; default: $this->editProducts($view, $options); $this->addCoupon($view); } parent::process(); /** client/html/basket/standard/check * Alters the behavior of the product checks before continuing with the checkout * * By default, the product related checks are performed every time the basket * is shown. They test if there are any products in the basket and execute all * basket plugins that have been registered for the "check.before" and "check.after" * events. * * Using this configuration setting, you can either disable all checks completely * (0) or display a "Check" button instead of the "Checkout" button (2). In the * later case, customers have to click on the "Check" button first to perform * the checks and if everything is OK, the "Checkout" button will be displayed * that allows the customers to continue the checkout process. If one of the * checks fails, the customers have to fix the related basket item and must click * on the "Check" button again before they can continue. * * Available values are: * 0 = no product related checks * 1 = checks are performed every time when the basket is displayed * 2 = checks are performed only when clicking on the "check" button * * @param integer One of the allowed values (0, 1 or 2) * @since 2016.08 * @category Developer * @category User */ $check = (int) $view->config('client/html/basket/standard/check', 1); switch ($check) { case 2: if ($view->param('b_check', 0) == 0) { break; } case 1: $controller->get()->check(\Aimeos\MShop\Order\Item\Base\Base::PARTS_PRODUCT); default: $view->standardCheckout = true; } } catch (\Aimeos\Client\Html\Exception $e) { $error = array($context->getI18n()->dt('client', $e->getMessage())); $view->standardErrorList = $view->get('standardErrorList', array()) + $error; } catch (\Aimeos\Controller\Frontend\Exception $e) { $error = array($context->getI18n()->dt('controller/frontend', $e->getMessage())); $view->standardErrorList = $view->get('standardErrorList', array()) + $error; } catch (\Aimeos\MShop\Plugin\Provider\Exception $e) { $errors = array($context->getI18n()->dt('mshop', $e->getMessage())); $errors = array_merge($errors, $this->translatePluginErrorCodes($e->getErrorCodes())); $view->standardErrorCodes = $e->getErrorCodes(); $view->standardErrorList = $view->get('standardErrorList', array()) + $errors; } catch (\Aimeos\MShop\Exception $e) { $error = array($context->getI18n()->dt('mshop', $e->getMessage())); $view->standardErrorList = $view->get('standardErrorList', array()) + $error; } catch (\Exception $e) { $context->getLogger()->log($e->getMessage() . PHP_EOL . $e->getTraceAsString()); $error = array($context->getI18n()->dt('client', 'A non-recoverable error occured')); $view->standardErrorList = $view->get('standardErrorList', array()) + $error; } // store updated basket after plugins updated content and have thrown an exception $controller->save(); }