public function setShippingMethodAction() { $methodCode = $this->_getParam('method'); // methodCode can include method type also - Pickup_Standard|Ups_Standard_WXS list($moduleName, $methodName) = explode('_', $methodCode); if (!in_array($moduleName . '_' . $methodName, Axis_Shipping::getMethodNames())) { Axis::message()->addError(Axis::translate('checkout')->__("'%s' method not found among installed modules", $methodCode)); $this->_redirect('/paymentpaypal/express/shipping-method'); } $method = Axis_Shipping::getMethod($methodCode); if (!$method instanceof Axis_Method_Shipping_Model_Abstract || !$method->isEnabled() || !$method->isAllowed($this->_getCheckout()->getShippingRequest())) { Axis::message()->addError(Axis::translate('checkout')->__('Selected shipping method in not allowed')); $this->_redirect('/paymentpaypal/express/shipping-method'); } $this->_getCheckout()->setShippingMethod($methodCode); $this->_redirect('/paymentpaypal/express/confirmation'); }
/** * Apply Shipping method if possible * * @param mixed $data * @return void * @throws Axis_Exception */ public function setShippingMethod($data) { if (!is_array($data)) { $data = array('method' => $data); } if (empty($data['method'])) { return $this->setShippingMethodCode(null); } // methodCode can include method type also - Pickup_Standard|Ups_Standard_WXS list($moduleName, $methodName) = explode('_', $data['method']); if (!in_array($moduleName . '_' . $methodName, Axis_Shipping::getMethodNames())) { throw new Axis_Exception(Axis::translate('checkout')->__("'%s' method not found among installed modules", $data['method'])); } $method = Axis_Shipping::getMethod($data['method']); if (!$method instanceof Axis_Method_Shipping_Model_Abstract || !$method->isAllowed($this->getShippingRequest())) { throw new Axis_Exception(Axis::translate('checkout')->__('Selected shipping method is not allowed')); } $this->_shipping = $method; $this->setShippingMethodCode($data['method']); }