public function listAction() { $this->_helper->layout->disableLayout(); $countryId = (int) $this->_getParam('country_id', 0); $zoneId = (int) $this->_getParam('zone_id', 0); $quantity = (double) $this->_getParam('quantity', 0); $weight = (double) $this->_getParam('weight', 0); $subtotal = (double) $this->_getParam('subtotal', 0); $shippingMethodCode = $this->_getParam('shipping_method_code', null); if (empty($shippingMethodCode)) { $shippingMethodCode = null; } $request = array('boxes' => 1, 'qty' => $quantity, 'weight' => $weight, 'price' => $subtotal, 'shipping_method_code' => $shippingMethodCode); $request['country'] = Axis::model('location/country')->find($countryId)->current()->toArray(); $request['zone'] = Axis::model('location/zone')->find($zoneId)->current()->toArray(); $allowedMethods = Axis_Payment::getAllowedMethods($request); $data = array(); foreach ($allowedMethods['methods'] as $method) { $data[] = array('code' => $method['code'], 'name' => $method['title'], 'form' => $this->view->paymentForm($method['code'], 'form')); } return $this->_helper->json->setData($data)->sendSuccess(); }
/** * Updates shopping cart totals, available shipping and payment methods * Unset shipping and payment methods if needed */ public function updateShoppingCartAction() { $this->_helper->layout->disableLayout(); $checkout = $this->_getCheckout(); $cart = Axis::single('checkout/cart'); foreach ($this->_getParam('quantity') as $itemId => $quantity) { $cart->updateItem($itemId, $quantity); } $products = $checkout->getCart()->getProducts(); if (!count($products)) { return $this->_helper->json->sendSuccess(array('redirect' => $this->view->href('checkout/cart', true))); } $shippingMethods = Axis_Shipping::getAllowedMethods($checkout->getShippingRequest()); $paymentMethods = Axis_Payment::getAllowedMethods($checkout->getPaymentRequest()); $this->view->checkout = array('shipping_methods' => $shippingMethods, 'payment_methods' => $paymentMethods, 'products' => $products, 'totals' => $checkout->getTotal()->getCollects(), 'total' => $checkout->getTotal()->getTotal()); return $this->_helper->json->sendSuccess(array('sections' => $this->_renderSections(array('shopping-cart', 'shipping-method', 'payment-method')))); }