public function actionShipping() { $this->step = 2; $cart = cart::model()->findByPk(Yii::app()->user->getState('cart_ID')); if ($_POST['carrier'] && !empty($_POST['carrier'])) { if ($model = carrier_entity::model()->findByPk($_POST['carrier'])) { $cart->cart_carrier_ID = intval($_POST['carrier']); $cart->save(); $this->redirect(array('payment')); exit; } } if (!isset($cart->cart_address_ID) or empty($cart->cart_address_ID)) { $this->redirect(array('index')); } $address = address_entity::model()->findByPk($cart->cart_address_ID); $zoneID = $address->getZoneId(); $carrier = carrier_entity::getByZone($zoneID); foreach ($carrier as $key => $row) { if (!($weightID = weight_range::validateCarrier($cart->getWeightTotal(), $row['carrier_ID']))) { unset($carrier[$key]); continue; } $carrier[$key]['price'] = $cart->getOrderShippingCost($row['carrier_ID']); $carrier[$key]['selected'] = false; if ($cart->cart_carrier_ID == $row['carrier_ID']) { $carrier[$key]['selected'] = true; } } $this->render('shipping', array('carrier' => $carrier)); }
public function loadModel() { if ($this->_model == null) { if (isset($_GET['id'])) { $condition = ''; $this->_model = carrier_entity::model()->findByPk($_GET['id'], $condition); } else { $this->_model = carrier_entity::model()->find('carrier_active=1 AND carrier_deleted=2'); } } return $this->_model; }
public function loadModel() { if ($this->_model == null) { if (isset($_GET['id'])) { $condition = ''; $this->_model = carrier_entity::model()->findByPk($_GET['id'], $condition); } if ($this->_model == null) { throw new CHttpException(404, "The requested page does not exist!"); } } return $this->_model; }
/** * Return shipping total * * @param integer $Carrier_ID Carrier ID (default : current carrier) * @return float Shipping total */ public function getOrderShippingCost($carrier_ID = NULL) { if ($this->isFreeshipping()) { return 0; } // Get id zone if (isset($this->cart_address_ID) and $this->cart_address_ID) { $id_zone = address_entity::model()->findByPk($this->cart_address_ID)->getZoneId(); } else { $id_zone = 1; } //if no carrier selectd,chosen default one if (!$carrier_ID) { $carrier_ID = $this->cart_carrier_ID; } if (empty($carrier_ID)) { return 0; } if (!($carrier = carrier_entity::model()->findByPk($carrier_ID))) { throw new CHttpException(500, 'No Carrier Chosen'); } if ($carrier->carrier_shipping_handing != 1) { return 0; } if (!($weightID = weight_range::validateCarrier($this->getWeightTotal(), $carrier_ID))) { return 'Out'; } $shippingCost = 0; if ($delivery = delivery::model()->findByAttributes(array('carrier_ID' => $carrier_ID, 'zone_ID' => $id_zone, 'weight_range_ID' => $weightID))) { $shippingCost = $delivery->price; } return $shippingCost; }