/** * 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(); // only start if there's something to do if (($option = $view->param('cs_option_terms', null)) === null) { return; } if (($option = $view->param('cs_option_terms_value', 0)) != 1) { $view->standardStepActive = 'summary'; $view->termsError = true; $error = array($view->translate('client/html', 'Please accept the terms and conditions')); $view->standardErrorList = $error + $view->get('standardErrorList', array()); } parent::process(); }
/** * 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(); $config = $context->getConfig(); $session = $context->getSession(); $name = $config->get('client/html/locale/select/currency/param-name', 'loc_currencyid'); if (($currencyId = $view->param($name)) !== null) { $session->set('aimeos/locale/currencyId', $currencyId); } parent::process(); }
/** * 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(); try { $provider = $this->_getServiceProvider($view->param('code')); $config = array('absoluteUri' => true, 'namespace' => false); $params = array('code' => $view->param('code'), 'orderid' => $view->param('orderid')); $urls = array('payment.url-success' => $this->_getUrlConfirm($view, $params, $config), 'payment.url-update' => $this->_getUrlUpdate($view, $params, $config)); $urls['payment.url-self'] = $urls['payment.url-update']; $provider->injectGlobalConfigBE($urls); $response = null; $headers = array(); try { $body = $view->request()->getBody(); if (($orderItem = $provider->updateSync($view->param(), $body, $response, $headers)) !== null) { Controller_Frontend_Factory::createController($context, 'order')->update($orderItem); // stock, coupons } $view->updateMessage = $response; } catch (MShop_Service_Exception $e) { $view->updateMessage = $e->getMessage(); } if (!empty($headers)) { $view->updateHttpHeaders = $headers; } parent::process(); } catch (Exception $e) { /** client/html/checkout/standard/update/http-error * HTTP header sent for failed attempts to update the order status * * This HTTP header is returned to the remote system if the status * update failed due to an error in the application. This header is * not sent if e.g. a payment was refused by the payment gateway! * It should be one of the 5xx HTTP headers. * * @param array List of valid HTTP headers * @since 2015.07 * @category Developer * @see client/html/checkout/standard/update/http-success */ $default = array('HTTP/1.1 500 Error updating order status'); $headerList = $context->getConfig()->get('client/html/checkout/standard/update/http-error', $default); $view->updateHttpHeaders = $headerList; $view->updateMessage = $e->getMessage(); $body = $view->request()->getBody(); $params = print_r($view->param(), true); $msg = "Updating order status failed: %1\$s\n%2\$s\n%3\$s"; $context->getLogger()->log(sprintf($msg, $e->getMessage(), $params, $body)); } }
/** * 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() { try { parent::process(); } catch (Client_Html_Exception $e) { $view = $this->getView(); $error = array($this->_getContext()->getI18n()->dt('client/html', $e->getMessage())); $view->sessionErrorList = $view->get('sessionErrorList', array()) + $error; } catch (Controller_Frontend_Exception $e) { $view = $this->getView(); $error = array($this->_getContext()->getI18n()->dt('controller/frontend', $e->getMessage())); $view->sessionErrorList = $view->get('sessionErrorList', array()) + $error; } catch (MShop_Exception $e) { $view = $this->getView(); $error = array($this->_getContext()->getI18n()->dt('mshop', $e->getMessage())); $view->sessionErrorList = $view->get('sessionErrorList', array()) + $error; } catch (Exception $e) { $context = $this->_getContext(); $context->getLogger()->log($e->getMessage() . PHP_EOL . $e->getTraceAsString()); $view = $this->getView(); $error = array($context->getI18n()->dt('client/html', 'A non-recoverable error occured')); $view->sessionErrorList = $view->get('sessionErrorList', 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(); $ids = $view->param('wat_id', array()); if ($context->getUserId() != null && !empty($ids)) { $typeItem = $this->_getTypeItem('customer/list/type', 'product', 'watch'); $manager = MShop_Factory::createManager($context, 'customer/list'); $search = $manager->createSearch(); $expr = array($search->compare('==', 'customer.list.parentid', $context->getUserId()), $search->compare('==', 'customer.list.refid', $ids), $search->compare('==', 'customer.list.domain', 'product'), $search->compare('==', 'customer.list.typeid', $typeItem->getId())); $search->setConditions($search->combine('&&', $expr)); $items = array(); foreach ($manager->searchItems($search) as $item) { $items[$item->getRefId()] = $item; } switch ($view->param('wat_action')) { case 'add': $search = $manager->createSearch(); $expr = array($search->compare('==', 'customer.list.parentid', $context->getUserId()), $search->compare('==', 'customer.list.typeid', $typeItem->getId()), $search->compare('==', 'customer.list.domain', 'product')); $search->setConditions($search->combine('&&', $expr)); $search->setSlice(0, 0); $total = 0; $manager->searchItems($search, array(), $total); /** client/html/account/watch/default/maxitems * Maximum number of products that can be watched in parallel * * This option limits the number of products that can be watched * after the users added the products to their watch list. * It must be a positive integer value greater than 0. * * Note: It's recommended to set this value not too high as this * leads to a high memory consumption when the e-mails are generated * to notify the customers. The memory used will up to 100*maxitems * of the footprint of one product item including the associated * texts, prices and media. * * @param integer Number of products * @since 2014.09 * @category User * @category Developer */ $max = $context->getConfig()->get('client/html/account/watch/default/maxitems', 100); $item = $manager->createItem(); $item->setParentId($context->getUserId()); $item->setTypeId($typeItem->getId()); $item->setDomain('product'); $item->setStatus(1); foreach ((array) $view->param('wat_id', array()) as $id) { if ($total >= $max) { $error = array(sprintf($context->getI18n()->dt('client/html', 'You can only watch up to %1$s products'), $max)); $view->watchErrorList = $view->get('watchErrorList', array()) + $error; break; } if (!isset($items[$id])) { $item->setId(null); $item->setRefId($id); $manager->saveItem($item); $manager->moveItem($item->getId()); $total++; } } break; case 'edit': foreach ((array) $view->param('wat_id', array()) as $id) { if (isset($items[$id])) { $item = $items[$id]; $config = array('timeframe' => $view->param('wat_timeframe', 7), 'pricevalue' => $view->param('wat_pricevalue', '0.00'), 'price' => $view->param('wat_price', 0), 'stock' => $view->param('wat_stock', 0), 'currency' => $context->getLocale()->getCurrencyId()); $time = time() + ($config['timeframe'] + 1) * 86400; $item->setDateEnd(date('Y-m-d 00:00:00', $time)); $item->setConfig($config); $manager->saveItem($item); } } break; case 'delete': $listIds = array(); foreach ((array) $view->param('wat_id', array()) as $id) { if (isset($items[$id])) { $listIds[] = $items[$id]->getId(); } } $manager->deleteItems($listIds); break; } } parent::process(); }
/** * Stores the given or fetched billing address in the basket. */ public function process() { $context = $this->_getContext(); $view = $this->getView(); try { if (($id = $view->param('ca_delivery_delete', null)) !== null) { $customerAddressManager = MShop_Factory::createManager($context, 'customer/address'); $address = $customerAddressManager->getItem($id); if ($address->getRefId() != $context->getUserId()) { throw new Client_Html_Exception(sprintf('Address with ID "%1$s" not found', $id)); } $customerAddressManager->deleteItem($id); } // only start if there's something to do if ($view->param('ca_deliveryoption', null) === null) { return; } $basketCtrl = Controller_Frontend_Factory::createController($context, 'basket'); /** client/html/checkout/standard/address/delivery/disable-new * Disables the option to enter a different delivery address for an order * * Besides the billing address, customers can usually enter a different * delivery address as well. To suppress displaying the form fields for * a delivery address, you can set this configuration option to "1". * * Until 2015-02, the configuration option was available as * "client/html/common/address/delivery/disable-new" starting from 2014-03. * * @param boolean A value of "1" to disable, "0" enables the delivery address form * @since 2015.02 * @category User * @category Developer * @see client/html/checkout/standard/address/delivery/salutations * @see client/html/checkout/standard/address/delivery/mandatory * @see client/html/checkout/standard/address/delivery/optional * @see client/html/checkout/standard/address/delivery/hidden */ $disable = $view->config('client/html/checkout/standard/address/delivery/disable-new', false); $type = MShop_Order_Item_Base_Address_Abstract::TYPE_DELIVERY; if (($option = $view->param('ca_deliveryoption', 'null')) === 'null' && $disable === false) { $params = $view->param('ca_delivery', array()); $invalid = $this->_checkFields($params); if (count($invalid) > 0) { $view->deliveryError = $invalid; throw new Client_Html_Exception(sprintf('At least one delivery address part is missing or invalid')); } $basketCtrl->setAddress($type, $params); } else { if (($option = $view->param('ca_deliveryoption', 'null')) !== '-1') { $customerAddressManager = MShop_Factory::createManager($context, 'customer/address'); $address = $customerAddressManager->getItem($option); if ($address->getRefId() != $context->getUserId()) { throw new Client_Html_Exception(sprintf('Address with ID "%1$s" not found', $option)); } $invalid = array(); $params = $view->param('ca_delivery_' . $option, array()); if (!empty($params)) { $list = array(); $invalid = $this->_checkFields($params); foreach ($params as $key => $value) { $list[str_replace('order.base', 'customer', $key)] = $value; } $address->fromArray($list); $customerAddressManager->saveItem($address); } if (count($invalid) > 0) { $view->deliveryError = $invalid; throw new Client_Html_Exception(sprintf('At least one delivery address part is missing or invalid')); } $basketCtrl->setAddress($type, $address); } else { $basketCtrl->setAddress($type, null); } } parent::process(); } catch (Controller_Frontend_Exception $e) { $view->deliveryError = $e->getErrorList(); throw $e; } }
/** * 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() { try { parent::process(); } catch (Exception $e) { $this->_getContext()->getLogger()->log($e->getMessage() . PHP_EOL . $e->getTraceAsString()); } }
/** * Processes the input, e.g. provides the address form. * A view must be available and this method doesn't generate any output * besides setting view variables. */ public function process() { $view = $this->getView(); $basket = $view->orderBasket; $customerId = $basket->getCustomerId(); try { $addr = $basket->getAddress(MShop_Order_Item_Base_Address_Abstract::TYPE_DELIVERY); if ($customerId != '' && $addr->getAddressId() == '') { $addrManager = MShop_Factory::createManager($this->_getContext(), 'customer/address'); $orderAddrManager = MShop_Factory::createManager($this->_getContext(), 'order/base/address'); $item = $addrManager->createItem(); $item->setRefId($customerId); $item->copyFrom($addr); $addrManager->saveItem($item); $addr->setAddressId($item->getId()); $orderAddrManager->saveItem($addr, false); } } catch (Exception $e) { $msg = sprintf('Unable to save address for customer "%1$s": %2$s', $customerId, $e->getMessage()); $this->_getContext()->getLogger()->log($msg, MW_Logger_Abstract::INFO); } parent::process(); }
/** * 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(); $session = $context->getSession(); $orderid = $session->get('arcavias/orderid'); try { if (($orderItem = $this->_updatePayment($view, $orderid)) === null) { $orderManager = MShop_Factory::createManager($context, 'order'); $orderItem = $orderManager->getItem($orderid); } $view->confirmOrderItem = $orderItem; parent::process(); if ($orderItem->getPaymentStatus() > MShop_Order_Item_Abstract::PAY_REFUSED) { foreach ($session->get('arcavias/basket/cache', array()) as $key => $value) { $session->set($key, null); } Controller_Frontend_Factory::createController($context, 'basket')->clear(); } if ($orderItem->getPaymentStatus() == MShop_Order_Item_Abstract::PAY_RECEIVED) { $orderBaseManager = MShop_Factory::createManager($context, 'order/base'); $orderBase = $orderBaseManager->load($orderItem->getBaseId()); $attributeManager = MShop_Factory::createManager($context, 'attribute'); $downloadManager = MShop_Factory::createManager($context, 'download'); foreach ($orderBase->getProducts() as $product) { $dfProdAttr = $product->getAttributeItem('digital-file', 'hidden'); $dfAttr = $attributeManager->getItem($dfProdAttr->getAttributeId(), array('media')); $listItems = $dfAttr->getRefItems('media'); $media = reset($listItems); $download = $downloadManager->createItem(); $download->setUserId($context->getUserId()); $download->setFileId($this->_generateId()); $download->setProductId($product->getId()); $download->setOrderBaseId($orderBase->getId()); $download->setUrl($media->getUrl()); $download->setDownloads(0); $downloadManager->saveItem($download); } } // Update stock, coupons, etc. Controller_Frontend_Factory::createController($context, 'order')->update($orderItem); } catch (Client_Html_Exception $e) { $error = array($context->getI18n()->dt('client/html', $e->getMessage())); $view->confirmErrorList = $view->get('confirmErrorList', array()) + $error; } catch (Controller_Frontend_Exception $e) { $error = array($context->getI18n()->dt('controller/frontend', $e->getMessage())); $view->confirmErrorList = $view->get('confirmErrorList', array()) + $error; } catch (MShop_Exception $e) { $error = array($context->getI18n()->dt('mshop', $e->getMessage())); $view->confirmErrorList = $view->get('confirmErrorList', array()) + $error; } catch (Exception $e) { $context->getLogger()->log($e->getMessage() . PHP_EOL . $e->getTraceAsString()); $error = array($context->getI18n()->dt('client/html', 'A non-recoverable error occured')); $view->confirmErrorList = $view->get('confirmErrorList', array()) + $error; } }
/** * Processes the input, e.g. store given order. * A view must be available and this method doesn't generate any output * besides setting view variables. */ public function process() { $view = $this->getView(); try { // only start if there's something to do if (($option = $view->param('cs_order', null)) === null || $view->get('standardStepActive') !== null) { return; } $context = $this->_getContext(); $orderBaseManager = MShop_Factory::createManager($context, 'order/base'); $basket = $orderBaseManager->getSession(); $basket->setCustomerId($context->getUserId()); $basket->finish(); $cntl = Controller_Frontend_Factory::createController($context, 'order'); $orderItem = $cntl->store($basket); $cntl->block($orderItem); $context->getSession()->set('arcavias/orderid', $orderItem->getId()); $view->orderItem = $orderItem; $view->orderBasket = $basket; parent::process(); // save again after sub-clients modified it's state MShop_Factory::createManager($context, 'order')->saveItem($orderItem); } catch (Exception $e) { $view->standardStepActive = 'order'; throw $e; } }
/** * 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(); if ($view->param('cs_order', null) === null) { return; } try { $controller = Controller_Frontend_Factory::createController($this->_getContext(), 'basket'); $controller->get()->check(MShop_Order_Item_Base_Abstract::PARTS_ALL); parent::process(); } catch (Exception $e) { $view->standardStepActive = 'summary'; throw $e; } }
/** * Modifies the cached body content to replace content based on sessions or cookies. * * @param string $content Cached content * @param string $uid Unique identifier for the output if the content is placed more than once on the same page * @return string Modified body content */ public function modifyBody($content, $uid) { $content = parent::modifyBody($content, $uid); return $this->_replaceSection($content, $this->getView()->csrf()->formfield(), 'catalog.detail.basket.csrf'); }
/** * 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() { parent::process(); }
/** * 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(); try { parent::process(); } catch (Client_Html_Exception $e) { $error = array($this->_getContext()->getI18n()->dt('client/html', $e->getMessage())); $view->standardErrorList = $view->get('standardErrorList', array()) + $error; } catch (Controller_Frontend_Exception $e) { $error = array($this->_getContext()->getI18n()->dt('controller/frontend', $e->getMessage())); $view->standardErrorList = $view->get('standardErrorList', array()) + $error; } catch (MShop_Plugin_Provider_Exception $e) { $errors = array($this->_getContext()->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 (MShop_Exception $e) { $error = array($this->_getContext()->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/html', 'A non-recoverable error occured')); $view->standardErrorList = $view->get('standardErrorList', array()) + $error; } }
/** * Processes the input, e.g. provides the account form. * A view must be available and this method doesn't generate any output * besides setting view variables. */ public function process() { $view = $this->getView(); $basket = $view->orderBasket; if ($basket->getCustomerId() == '') { $email = '<unknown>'; $context = $this->_getContext(); try { $addr = $basket->getAddress(MShop_Order_Item_Base_Address_Abstract::TYPE_PAYMENT); $email = $addr->getEmail(); $manager = MShop_Factory::createManager($context, 'customer'); $search = $manager->createSearch(); $search->setConditions($search->compare('==', 'customer.code', $email)); $search->setSlice(0, 1); $result = $manager->searchItems($search); if (empty($result)) { $orderBaseManager = MShop_Factory::createManager($context, 'order/base'); $item = $this->_addCustomerData($manager->createItem(), $addr); $manager->saveItem($item); $context->setUserId($item->getId()); $basket->setCustomerId($item->getId()); $orderBaseManager->saveItem($basket, false); } } catch (Exception $e) { $msg = sprintf('Unable to create customer account for "%1$s": %2$s', $email, $e->getMessage()); $context->getLogger()->log($msg, MW_Logger_Abstract::INFO); } } parent::process(); }
/** * 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() { if (($id = $this->getView()->param('d_prodid')) !== null) { $context = $this->_getContext(); $session = $context->getSession(); $lastSeen = $session->get('arcavias/catalog/session/seen/list', array()); if (isset($lastSeen[$id])) { $html = $lastSeen[$id]; unset($lastSeen[$id]); $lastSeen[$id] = $html; } else { /** client/html/catalog/session/seen/default/maxitems * Maximum number of products displayed in the "last seen" section * * This option limits the number of products that are shown in the * "last seen" section after the user visited their detail pages. It * must be a positive integer value greater than 0. * * @param integer Number of products * @since 2014.03 * @category User * @category Developer */ $max = $this->_getContext()->getConfig()->get('client/html/catalog/session/seen/default/maxitems', 6); $lastSeen[$id] = $this->_getHtml($id); $lastSeen = array_slice($lastSeen, -$max, $max, true); } $session->set('arcavias/catalog/session/seen/list', $lastSeen); foreach ($session->get('arcavias/catalog/session/seen/cache', array()) as $key => $value) { $session->set($key, null); } } parent::process(); }
/** * 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(); try { parent::process(); $basketCntl = Controller_Frontend_Factory::createController($this->_getContext(), 'basket'); // Test if addresses are available $addresses = $basketCntl->get()->getAddresses(); if (!isset($view->standardStepActive) && count($addresses) === 0) { $view->standardStepActive = 'address'; return false; } } catch (Exception $e) { $this->getView()->standardStepActive = 'address'; throw $e; } }
/** * 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() { $context = $this->_getContext(); $view = $this->getView(); try { $params = $this->_getClientParams($view->param()); $context->getSession()->set('arcavias/catalog/detail/params/last', $params); parent::process(); } catch (Client_Html_Exception $e) { $error = array($context->getI18n()->dt('client/html', $e->getMessage())); $view->detailErrorList = $view->get('detailErrorList', array()) + $error; } catch (Controller_Frontend_Exception $e) { $error = array($context->getI18n()->dt('controller/frontend', $e->getMessage())); $view->detailErrorList = $view->get('detailErrorList', array()) + $error; } catch (MShop_Exception $e) { $error = array($context->getI18n()->dt('mshop', $e->getMessage())); $view->detailErrorList = $view->get('detailErrorList', array()) + $error; } catch (Exception $e) { $context->getLogger()->log($e->getMessage() . PHP_EOL . $e->getTraceAsString()); $error = array($context->getI18n()->dt('client/html', 'A non-recoverable error occured')); $view->detailErrorList = $view->get('detailErrorList', array()) + $error; } }
/** * Stores the given or fetched billing address in the basket. */ public function process() { $view = $this->getView(); try { // only start if there's something to do if ($view->param('ca_billingoption', null) === null) { return; } $context = $this->_getContext(); $basketCtrl = Controller_Frontend_Factory::createController($context, 'basket'); /** client/html/checkout/standard/address/billing/disable-new * Disables the option to enter a new billing address for an order * * Besides the main billing address, customers can usually enter a new * billing address as well. To suppress displaying the form fields for * a billing address, you can set this configuration option to "1". * * Until 2015-02, the configuration option was available as * "client/html/common/address/billing/disable-new" starting from 2014-03. * * @param boolean A value of "1" to disable, "0" enables the billing address form * @since 2015.02 * @category User * @category Developer * @see client/html/checkout/standard/address/billing/salutations * @see client/html/checkout/standard/address/billing/mandatory * @see client/html/checkout/standard/address/billing/optional * @see client/html/checkout/standard/address/billing/hidden */ $disable = $view->config('client/html/checkout/standard/address/billing/disable-new', false); $type = MShop_Order_Item_Base_Address_Abstract::TYPE_PAYMENT; if (($option = $view->param('ca_billingoption', 'null')) === 'null' && $disable === false) { $params = $view->param('ca_billing', array()); $invalid = $this->_checkFields($params); if (count($invalid) > 0) { $view->billingError = $invalid; throw new Client_Html_Exception(sprintf('At least one billing address part is missing or invalid')); } $basketCtrl->setAddress($type, $params); } else { $customerManager = MShop_Factory::createManager($context, 'customer'); $search = $customerManager->createSearch(true); $expr = array($search->compare('==', 'customer.id', $option), $search->getConditions()); $search->setConditions($search->combine('&&', $expr)); $items = $customerManager->searchItems($search); if (($item = reset($items)) === false || $option != $context->getUserId()) { throw new Client_Html_Exception(sprintf('Customer with ID "%1$s" not found', $option)); } $invalid = array(); $addr = $item->getPaymentAddress(); $params = $view->param('ca_billing_' . $option, array()); if (!empty($params)) { $list = array(); $invalid = $this->_checkFields($params); foreach ($params as $key => $value) { $list[str_replace('order.base', 'customer', $key)] = $value; } $addr->fromArray($list); $item->setPaymentAddress($addr); $customerManager->saveItem($item); } if (count($invalid) > 0) { $view->billingError = $invalid; throw new Client_Html_Exception(sprintf('At least one billing address part is missing or invalid')); } $basketCtrl->setAddress($type, $addr); } parent::process(); } catch (Controller_Frontend_Exception $e) { $view->billingError = $e->getErrorList(); throw $e; } }
/** * 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(); $ids = $view->param('fav_id', array()); if ($context->getUserId() != null && !empty($ids)) { $typeItem = $this->_getTypeItem('customer/list/type', 'product', 'favorite'); $manager = MShop_Factory::createManager($context, 'customer/list'); $search = $manager->createSearch(); $expr = array($search->compare('==', 'customer.list.parentid', $context->getUserId()), $search->compare('==', 'customer.list.refid', $ids), $search->compare('==', 'customer.list.domain', 'product'), $search->compare('==', 'customer.list.typeid', $typeItem->getId())); $search->setConditions($search->combine('&&', $expr)); $items = array(); foreach ($manager->searchItems($search) as $item) { $items[$item->getRefId()] = $item; } switch ($view->param('fav_action')) { case 'add': $item = $manager->createItem(); $item->setParentId($context->getUserId()); $item->setTypeId($typeItem->getId()); $item->setDomain('product'); $item->setStatus(1); foreach ((array) $view->param('fav_id', array()) as $id) { if (!isset($items[$id])) { $item->setId(null); $item->setRefId($id); $manager->saveItem($item); $manager->moveItem($item->getId()); } } break; case 'delete': $listIds = array(); foreach ((array) $view->param('fav_id', array()) as $id) { if (isset($items[$id])) { $listIds[] = $items[$id]->getId(); } } $manager->deleteItems($listIds); break; } } parent::process(); }
/** * 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(); try { $context = $this->_getContext(); $basketCtrl = Controller_Frontend_Factory::createController($context, 'basket'); // only start if there's something to do if (($serviceId = $view->param('c_paymentoption', null)) !== null) { $serviceCtrl = Controller_Frontend_Factory::createController($context, 'service'); $attributes = $view->param('c_payment/' . $serviceId, array()); $errors = $serviceCtrl->checkServiceAttributes('payment', $serviceId, $attributes); foreach ($errors as $key => $msg) { if ($msg === null) { unset($errors[$key]); } } if (count($errors) === 0) { $basketCtrl->setService('payment', $serviceId, $attributes); } else { $view->standardStepActive = 'payment'; } $view->paymentError = $errors; } parent::process(); // Test if payment service is available $services = $basketCtrl->get()->getServices(); if (!isset($view->standardStepActive) && !array_key_exists('payment', $services)) { $view->standardStepActive = 'payment'; return false; } } catch (Exception $e) { $view->standardStepActive = 'payment'; throw $e; } }
/** * Processes the input, e.g. store given order. * A view must be available and this method doesn't generate any output * besides setting view variables. */ public function process() { $view = $this->getView(); if (!in_array($view->param('c_step'), array('order', 'process'))) { return; } $context = $this->_getContext(); $session = $context->getSession(); $orderid = $session->get('arcavias/orderid'); $config = array('absoluteUri' => true, 'namespace' => false); try { $orderItem = MShop_Factory::createManager($context, 'order')->getItem($orderid); if (($code = $this->_getOrderServiceCode($orderItem->getBaseId())) !== null) { $serviceItem = $this->_getServiceItem($code); $serviceManager = MShop_Factory::createManager($context, 'service'); $provider = $serviceManager->getProvider($serviceItem); $params = array('code' => $serviceItem->getCode(), 'orderid' => $orderid); $urls = array('payment.url-self' => $this->_getUrlSelf($view, $params + array('c_step' => 'process'), array()), 'payment.url-success' => $this->_getUrlConfirm($view, $params, $config), 'payment.url-update' => $this->_getUrlUpdate($view, $params, $config), 'client.ipaddress' => $view->request()->getClientAddress()); $provider->injectGlobalConfigBE($urls); if (($form = $provider->process($orderItem, $view->param())) === null) { $msg = sprintf('Invalid process response from service provider with code "%1$s"', $serviceItem->getCode()); throw new Client_Html_Exception($msg); } $view->standardUrlNext = $form->getUrl(); $view->standardMethod = $form->getMethod(); $view->standardProcessParams = $form->getValues(); $view->standardUrlExternal = $form->getExternal(); } else { $view->standardUrlNext = $this->_getUrlConfirm($view, array(), array()); $view->standardMethod = 'GET'; } parent::process(); } catch (Client_Html_Exception $e) { $error = array($context->getI18n()->dt('client/html', $e->getMessage())); $view->standardErrorList = $view->get('standardErrorList', array()) + $error; } catch (Controller_Frontend_Exception $e) { $error = array($context->getI18n()->dt('controller/frontend', $e->getMessage())); $view->standardErrorList = $view->get('standardErrorList', array()) + $error; } catch (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/html', 'A non-recoverable error occured')); $view->standardErrorList = $view->get('standardErrorList', array()) + $error; } $view->standardUrlPayment = $this->_getUrlSelf($view, array('c_step' => 'payment'), array()); }
/** * 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(); $session = $context->getSession(); try { $orderid = $session->get('arcavias/orderid'); $provider = $this->_getServiceProvider($view->param('code')); $config = array('absoluteUri' => true, 'namespace' => false); $params = array('code' => $view->param('code'), 'orderid' => $orderid); $urls = array('payment.url-success' => $this->_getUrlConfirm($view, $params, $config), 'payment.url-update' => $this->_getUrlUpdate($view, $params, $config), 'client.ipaddress' => $view->request()->getClientAddress()); $urls['payment.url-self'] = $urls['payment.url-success']; $provider->injectGlobalConfigBE($urls); $reqParams = $view->param(); $reqParams['orderid'] = $orderid; if (($orderItem = $provider->updateSync($reqParams, $view->request()->getBody())) !== null) { if ($orderItem->getPaymentStatus() === MShop_Order_Item_Abstract::PAY_UNFINISHED && $provider->isImplemented(MShop_Service_Provider_Payment_Abstract::FEAT_QUERY)) { $provider->query($orderItem); } $view->confirmOrderItem = $orderItem; } else { return; } parent::process(); if ($orderItem->getPaymentStatus() > MShop_Order_Item_Abstract::PAY_REFUSED) { foreach ($session->get('arcavias/basket/cache', array()) as $key => $value) { $session->set($key, null); } Controller_Frontend_Factory::createController($context, 'basket')->clear(); } // Update stock, coupons, etc. Controller_Frontend_Factory::createController($context, 'order')->update($orderItem); } catch (Client_Html_Exception $e) { $error = array($context->getI18n()->dt('client/html', $e->getMessage())); $view->confirmErrorList = $view->get('confirmErrorList', array()) + $error; } catch (Controller_Frontend_Exception $e) { $error = array($context->getI18n()->dt('controller/frontend', $e->getMessage())); $view->confirmErrorList = $view->get('confirmErrorList', array()) + $error; } catch (MShop_Exception $e) { $error = array($context->getI18n()->dt('mshop', $e->getMessage())); $view->confirmErrorList = $view->get('confirmErrorList', array()) + $error; } catch (Exception $e) { $context->getLogger()->log($e->getMessage() . PHP_EOL . $e->getTraceAsString()); $error = array($context->getI18n()->dt('client/html', 'A non-recoverable error occured')); $view->confirmErrorList = $view->get('confirmErrorList', 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() { $refresh = false; $view = $this->getView(); $context = $this->_getContext(); $session = $context->getSession(); $pinned = $session->get('arcavias/catalog/session/pinned/list', array()); switch ($view->param('pin_action')) { case 'add': foreach ((array) $view->param('pin_id', array()) as $id) { $pinned[$id] = $id; } /** client/html/catalog/session/pinned/default/maxitems * Maximum number of products displayed in the "pinned" section * * This option limits the number of products that are shown in the * "pinned" section after the users added the product to their list * of pinned products. It must be a positive integer value greater * than 0. * * Note: The higher the value is the more data has to be transfered * to the client each time the user loads a page with the list of * pinned products. * * @param integer Number of products * @since 2014.09 * @category User * @category Developer */ $max = $context->getConfig()->get('client/html/catalog/session/pinned/default/maxitems', 50); $pinned = array_slice($pinned, -$max, $max, true); $refresh = true; break; case 'delete': foreach ((array) $view->param('pin_id', array()) as $id) { unset($pinned[$id]); } $refresh = true; break; } if ($refresh) { $session->set('arcavias/catalog/session/pinned/list', $pinned); foreach ($session->get('arcavias/catalog/session/pinned/cache', array()) as $key => $value) { $session->set($key, null); } } parent::process(); }