public function listAction()
 {
     function _calculateShippingTax($price, Axis_Method_Shipping_Model_Abstract $shipping, array $params)
     {
         $customerGroupId = $params['customer_group_id'];
         if (!($taxClassId = $shipping->config()->taxClass)) {
             if (!($taxClassId = Axis::config()->tax->shipping->taxClass)) {
                 return 0;
             }
         }
         if (!($taxBasis = $shipping->config()->taxBasis)) {
             if (!($taxBasis = Axis::config()->tax->shipping->taxBasis)) {
                 return 0;
             }
         }
         if ('billing' === $taxBasis) {
             $countryId = $params['billing_country_id'];
             $zoneId = $params['billing_zone_id'];
         } else {
             $countryId = $params['delivery_country_id'];
             $zoneId = $params['delivery_zone_id'];
         }
         if (empty($zoneId)) {
             $zoneId = null;
         }
         $geozoneIds = Axis::single('location/geozone')->getIds($countryId, $zoneId);
         if (empty($geozoneIds)) {
             return 0;
         }
         return Axis::single('tax/rate')->calculateByPrice($price, $taxClassId, $geozoneIds, $customerGroupId);
     }
     $this->_helper->layout->disableLayout();
     $params = $this->_getAllParams();
     $countryId = (int) $this->_getParam('delivery_country_id', 0);
     $zoneId = (int) $this->_getParam('delivery_zone_id', 0);
     $quantity = (double) $this->_getParam('quantity', 0);
     $weight = (double) $this->_getParam('weight', 0);
     $subtotal = (double) $this->_getParam('subtotal', 0);
     $paymentMethodCode = $this->_getParam('payment_method_code', null);
     if (empty($paymentMethodCode)) {
         $paymentMethodCode = null;
     }
     $postcode = $this->_getParam('postcode', null);
     $request = array('boxes' => 1, 'qty' => $quantity, 'weight' => $weight, 'price' => $subtotal, 'payment_method_code' => $paymentMethodCode, 'postcode' => $postcode);
     $request['country'] = Axis::model('location/country')->find($countryId)->current()->toArray();
     $request['zone'] = Axis::model('location/zone')->find($zoneId)->current()->toArray();
     $allowedMethods = Axis_Shipping::getAllowedMethods($request);
     $data = array();
     foreach ($allowedMethods['methods'] as $methodCode => $types) {
         $shipping = Axis_Shipping::getMethod($methodCode);
         $title = $shipping->getTitle();
         foreach ($types as $type) {
             $data[] = array('code' => $type['id'], 'title' => $type['title'], 'name' => $title . ' ' . $type['title'] . ' ' . $type['price'], 'price' => $type['price'], 'tax' => _calculateShippingTax($type['price'], $shipping, $params));
         }
     }
     return $this->_helper->json->setData($data)->sendSuccess();
 }
 public function shippingMethodAction()
 {
     $this->view->shippingMethods = Axis_Shipping::getAllowedMethods($this->_getCheckout()->getShippingRequest());
     $this->render('shipping');
 }
 /**
  * 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'))));
 }