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; }
</div> <div class="clear"></div> <div class="box-left"> <!--Order Information--> <div class="entry-edit"> <div class="entry-edit-head"> <h4 class="icon-head head-account">运费</h4> </div> <div class="grid fieldset"> <table cellspacing="0" cellpadding="0" class="table space"> <tbody> <?php echo "<tr>"; echo CHtml::activeDropDownList($carrier, 'carrier_ID', carrier_entity::items(), array('class' => 'required-entry required-entry input-select', 'id' => 'carrier', 'name' => 'carrier_ID')); echo "</tr>"; echo ' <tr class="headings"> <th style="padding:4px 6px;">区域 / 范围</th>'; foreach ($carrier->weight as $row) { $l1 = floatval($row->delimiter1); $l2 = floatval($row->delimiter2); echo "<th style='font-size: 11px; padding:4px 6px;'>{$l1}kg to {$l2}kg</th>"; } echo '</tr>'; foreach ($carrier->zones as $row) { echo "<tr class='filter'><th style='height: 30px; padding:4px 6px;'>{$row->name}</th>"; foreach ($carrier->weight as $item) { $delivery = delivery::model()->findByAttributes(array('carrier_ID' => $carrier->carrier_ID, 'zone_ID' => $row->zone_ID, 'weight_range_ID' => $item->weight_ID)); if ($delivery) { $fee = $delivery->price;
<div id="weightGrid"> <?php $this->widget('TradeGrid', array('dataProvider' => $model->search(), 'filter' => $model, 'htmlOptions' => array('class' => 'hor-scroll'), 'columns' => array(array('header' => '编号', 'name' => 'weight_ID', 'type' => 'raw'), array('header' => '货运渠道', 'name' => 'carrier_ID', 'value' => 'carrier_entity::model()->findByPk($data->carrier_ID)->carrier_name', 'filter' => carrier_entity::items(), 'type' => 'raw'), array('header' => '下限', 'name' => 'delimiter1', 'value' => '"KG" . $data->delimiter1', 'type' => 'raw'), array('header' => '上限', 'name' => 'delimiter2', 'value' => '"KG" . $data->delimiter2', 'type' => 'raw'), array('class' => 'CButtonColumn', 'template' => '{update} {delete}')))); ?> </div>