Beispiel #1
0
 public function loadModel()
 {
     if ($this->_model == null) {
         if (isset($_GET['id'])) {
             $condition = '';
             $this->_model = address_entity::model()->findByPk($_GET['id'], $condition);
         }
         if ($this->_model == null) {
             throw new CHttpException(404, "The requested page does not exist!");
         }
     }
     return $this->_model;
 }
Beispiel #2
0
 public function actionPayment()
 {
     $cart = cart::model()->findByPk(Yii::app()->user->getState('cart_ID'));
     if (!$cart->cart_address_ID or !$cart->cart_carrier_ID) {
         $this->redirect(array('index'));
         exit;
     }
     if (!($address = address_entity::model()->findByPk($cart->cart_address_ID))) {
         $this->redirect(array('index'));
         exit;
     }
     $grandTotal = product_entity::decoratePrice($cart->getOrderTotal(), true);
     $this->render('payment', array('grandTotal' => $grandTotal));
 }
Beispiel #3
0
 /**
  * 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;
 }