?> <?php echo $form->dropDownList($model, 'payment_method', CHtml::listData(PaymentMethod::model()->findAll(), 'id', function ($data) { return $data->getName(); })); ?> <?php echo $form->error($model, 'payment_method'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'shipping_method'); ?> <?php echo $form->dropDownList($model, 'shipping_method', CHtml::listData(ShippingMethod::model()->findAll(), 'id', function ($data) { return $data->getName(); })); ?> <?php echo $form->error($model, 'shipping_method'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'order_status_id'); ?> <?php echo $form->dropDownList($model, 'order_status_id', CHtml::listData(OrderStatus::model()->findAll(), 'id', function ($data) { return $data->getName(); }));
</div> </fieldset> <br /> <hr /> <h3> <?php echo Shop::t('Shipping Method'); ?> </h3> <p> <?php echo Shop::t('Choose your Shipping method'); ?> </p> <?php $i = 0; foreach (ShippingMethod::model()->findAll() as $method) { echo '<div class="row">'; echo CHtml::radioButton("ShippingMethod", $i == 0, array('value' => $method->id)); echo '<div class="float-left">'; echo CHtml::label($method->title, 'ShippingMethod'); echo CHtml::tag('p', array(), $method->description); echo CHtml::tag('p', array(), Shop::t('Price: ') . Shop::priceFormat($method->price)); echo '</div>'; echo '</div>'; echo '<div class="clear"></div>'; $i++; } ?>
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = ShippingMethod::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function loadModel($id, $weight_range = null) { if ($weight_range) { $model = ShippingMethod::model()->find('id = :id and weight_range = :weight_range', array(':id' => $id, ':weight_range' => $weight_range)); } else { $model = ShippingMethod::model()->find('id = :id', array(':id' => $id)); } if ($model === null) { throw new CHttpException(404, 'The requested shipping Method does not exist.'); } return $model; }
<?php $this->widget('bootstrap.widgets.TbAlert'); ?> <?php $this->widget('bootstrap.widgets.TbDetailView', array('data' => $model, 'attributes' => array('shipping_firstname', 'shipping_lastname', 'shipping_company', 'shipping_address_1', 'shipping_address_2', 'shipping_city', 'shipping_postcode', 'shipping_country', 'shipping_zone', 'shipping_address_format', array('label' => 'Shipping Method', 'type' => 'raw', 'value' => ShippingMethod::model()->findByPk($model->shipping_method)->getName()), 'shipping_code')));
<?php $methods = ShippingMethod::model()->findAll(); printf('<h2>%s</h2>', Shop::t('Available shipping methods')); if ($methods) { echo '<table>'; foreach ($methods as $method) { printf('<tr><td>%s</td><td>%s</td></tr>', $method->description, Shop::priceFormat($method->price)); } echo '</table>'; }
</table> <div class='row'> <div class="order-checkout-memo"> <div class="col-span-10 checkout-memo text-left"> <h3>给卖家留言:</h3> <?php echo CHtml::textArea('memo', '', array('placeholder' => '选填,可以告诉卖家您对商品的特殊要求,如:颜色、尺码等', 'class' => '')); ?> </div> <div class="col-span-2 express text-left"> <h3>配送方式:</h3> <span class="select-wrapper"> <?php $cri = new CDbCriteria(array('condition' => 'enabled = 1')); $shippingMethod = ShippingMethod::model()->findAll($cri); $list = CHtml::listData($shippingMethod, 'id', 'name'); echo CHtml::dropDownList('ship_method', '', $list); ?> <!-- <select> <option value="classic" selected="">Classic</option> <option value="classically">Classically</option> <option value="classicalest">Classicalest</option> </select>--> </span> </div> </div> </div> <div class="clearfix"></div> <div class="order-confirm text-right" style='margin-top:10px'><?php
/** Creation of a new Order * Before we create a new order, we need to gather Customer information. * If the user is logged in, we check if we already have customer information. * If so, we go directly to the Order confirmation page with the data passed * over. Otherwise we need the user to enter his data, and depending on * whether he is logged in into the system it is saved with his user * account or once just for this order. */ public function actionCreate($customer = null, $payment_method = null, $shipping_method = null) { // Shopping cart is empty, taking a order is not allowed yet if (Shop::getCartContent() == array()) { $this->redirect(array('//shop/shoppingCart/view')); } if (isset($_POST['ShippingMethod'])) { Yii::app()->user->setState('shipping_method', $_POST['ShippingMethod']); } if (isset($_POST['PaymentMethod'])) { Yii::app()->user->setState('payment_method', $_POST['PaymentMethod']); } if (isset($_POST['DeliveryAddress']) && @$_POST['toggle_delivery'] == true) { if (Address::isEmpty($_POST['DeliveryAddress'])) { Shop::setFlash(Shop::t('Delivery address is not complete! Please fill in all fields to set the Delivery address')); } else { $deliveryAddress = new DeliveryAddress(); $deliveryAddress->attributes = $_POST['DeliveryAddress']; if ($deliveryAddress->save()) { $model = Shop::getCustomer(); if (isset($_POST['toggle_delivery'])) { $model->delivery_address_id = $deliveryAddress->id; } else { $model->delivery_address_id = 0; } $model->save(false, array('delivery_address_id')); } } } if (isset($_POST['BillingAddress']) && @$_POST['toggle_billing'] == true) { if (Address::isEmpty($_POST['BillingAddress'])) { Shop::setFlash(Shop::t('Billing address is not complete! Please fill in all fields to set the Billing address')); } else { $BillingAddress = new BillingAddress(); $BillingAddress->attributes = $_POST['BillingAddress']; if ($BillingAddress->save()) { $model = Shop::getCustomer(); if (isset($_POST['toggle_billing'])) { $model->billing_address_id = $BillingAddress->id; } else { $model->billing_address_id = 0; } $model->save(false, array('billing_address_id')); } } } if (!$customer) { $customer = Yii::app()->user->getState('customer_id'); } if (!Yii::app()->user->isGuest && !$customer) { $customer = Customer::model()->find('user_id = :user_id ', array(':user_id' => Yii::app()->user->id)); } if (!$payment_method) { $payment_method = Yii::app()->user->getState('payment_method'); } if (!$shipping_method) { $shipping_method = Yii::app()->user->getState('shipping_method'); } if (!$customer) { $this->render('/customer/create', array('action' => array('//shop/customer/create'))); Yii::app()->end(); } if (!$shipping_method) { $this->render('/shippingMethod/choose', array('customer' => Shop::getCustomer())); Yii::app()->end(); } if (!$payment_method) { $this->render('/paymentMethod/choose', array('customer' => Shop::getCustomer())); Yii::app()->end(); } if ($customer && $payment_method && $shipping_method) { if (is_numeric($customer)) { $customer = Customer::model()->findByPk($customer); } if (is_numeric($shipping_method)) { $shipping_method = ShippingMethod::model()->find('id = :id', array(':id' => $shipping_method)); } if (is_numeric($payment_method)) { $payment_method = PaymentMethod::model()->findByPk($payment_method); } $this->render('/order/create', array('customer' => $customer, 'shippingMethod' => $shipping_method, 'paymentMethod' => $payment_method)); } }
public static function getShippingMethod() { if ($shipping_method = Yii::app()->user->getState('shipping_method')) { return ShippingMethod::model()->findByPk($shipping_method); } }
Shop::renderFlash(); echo CHtml::beginForm(array('//shop/order/confirm')); echo '<h2>' . Shop::t('Confirmation') . '</h2>'; if (Shop::getCartContent() == array()) { return false; } // If the customer is not passed over to the view, we assume the user is // logged in and we fetch the customer data from the customer table if (!isset($customer)) { $customer = Shop::getCustomer(); } $this->renderPartial('application.modules.shop.views.customer.view', array('model' => $customer, 'hideAddress' => true, 'hideEmail' => true)); echo '<br />'; echo '<hr />'; echo '<p>'; $shipping = ShippingMethod::model()->find('id = :id', array(':id' => Yii::app()->user->getState('shipping_method'))); echo '<strong>' . Shop::t('Shipping Method') . ': </strong>' . ' ' . $shipping->title . ' (' . $shipping->description . ')'; echo '<br />'; echo CHtml::link(Shop::t('Edit shipping method'), array('//shop/shippingMethod/choose', 'order' => true)); echo '</p>'; echo '<p>'; $payment = PaymentMethod::model()->findByPk(Yii::app()->user->getState('payment_method')); echo '<strong>' . Shop::t('Payment method') . ': </strong>' . ' ' . $payment->title . ' (' . $payment->description . ')'; echo '<br />'; echo CHtml::link(Shop::t('Edit payment method'), array('//shop/paymentMethod/choose', 'order' => true)); echo '</p>'; echo '<hr />'; $this->renderPartial('application.modules.shop.views.shoppingCart.view'); echo '<h3>' . Shop::t('Please add additional comments to the order here') . '</h3>'; echo CHtml::textArea('Order[Comment]', @Yii::app()->user->getState('order_comment'), array('class' => 'order_comment')); echo '<br /><br />';
public static function getShippingMethod($costs = false) { if ($shipping_method = Yii::app()->user->getState('shipping_method')) { $weight_total = Shop::getWeightTotal(); $methods = ShippingMethod::model()->findAll('id = :id', array(':id' => $shipping_method)); foreach ($methods as $method) { $range = explode('-', $method->weight_range); if (isset($range[0]) && isset($range[1]) && is_numeric($range[0]) && is_numeric($range[1])) { if ($range[0] <= $weight_total && $range[1] >= $weight_total) { if ($costs) { return Shop::priceFormat($method->getPrice()); } else { return $method; } } } } } }
Shop::renderFlash(); echo CHtml::beginForm(array('//shop/order/confirm')); echo '<h2>' . Shop::t('Confirmation') . '</h2>'; if (Shop::getCartContent() == array()) { return false; } // If the customer is not passed over to the view, we assume the user is // logged in and we fetch the customer data from the customer table if (!isset($customer)) { $customer = Shop::getCustomer(); } $this->renderPartial('application.modules.shop.views.customer.view', array('model' => $customer, 'hideAddress' => true, 'hideEmail' => true)); echo '<br />'; echo '<hr />'; echo '<p>'; $shipping = ShippingMethod::model()->findByPk(Yii::app()->user->getState('shipping_method')); echo '<strong>' . Shop::t('Shipping Method') . ': </strong>' . ' ' . $shipping->title . ' (' . $shipping->description . ')'; echo '<br />'; echo CHtml::link(Shop::t('Edit shipping method'), array('//shop/shippingMethod/choose', 'order' => true)); echo '</p>'; echo '<p>'; $payment = PaymentMethod::model()->findByPk(Yii::app()->user->getState('payment_method')); echo '<strong>' . Shop::t('Payment method') . ': </strong>' . ' ' . $payment->title . ' (' . $payment->description . ')'; echo '<br />'; echo CHtml::link(Shop::t('Edit payment method'), array('//shop/paymentMethod/choose', 'order' => true)); echo '</p>'; echo '<hr />'; $this->renderPartial('application.modules.shop.views.shoppingCart.view'); echo '<h3>' . Shop::t('Please add additional comments to the order here') . '</h3>'; echo CHtml::textArea('Order[Comment]', @Yii::app()->user->getState('order_comment'), array('style' => 'width:600px; height:100px;padding:10px;')); echo '<br /><br />';