当前位置: 首页>>代码示例>>PHP>>正文


PHP Shop::getCustomer方法代码示例

本文整理汇总了PHP中Shop::getCustomer方法的典型用法代码示例。如果您正苦于以下问题:PHP Shop::getCustomer方法的具体用法?PHP Shop::getCustomer怎么用?PHP Shop::getCustomer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Shop的用法示例。


在下文中一共展示了Shop::getCustomer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionCreate

 public function actionCreate()
 {
     if ($model = Shop::getCustomer()) {
         $address = $model->address;
     } else {
         $model = new Customer();
     }
     if (isset($_POST['Customer'])) {
         $model->attributes = $_POST['Customer'];
         if (isset($_POST['Address'])) {
             $address = new Address();
             $address->attributes = $_POST['Address'];
             if ($address->save()) {
                 $model->address_id = $address->id;
             }
         }
         if (!Yii::app()->user->isGuest) {
             $model->user_id = Yii::app()->user->id;
         }
         if ($model->save()) {
             Yii::app()->user->setState('customer_id', $model->customer_id);
             $this->redirect(array('//shop/order/create', 'customer' => $model->customer_id));
         }
     }
     $this->render('create', array('customer' => $model, 'address' => isset($address) ? $address : new Address()));
 }
开发者ID:huynhchanhuy,项目名称:yii_shopping,代码行数:26,代码来源:CustomerController.php

示例2: actionCreate

 public function actionCreate()
 {
     // if some data has been entered before or the user is already logged in,
     // take the already existing data and prefill the input form
     if ($model = Shop::getCustomer()) {
         $address = $model->address;
     } else {
         $model = new Customer();
     }
     if (isset($_POST['Customer'])) {
         $model->attributes = $_POST['Customer'];
         if (isset($_POST['Address'])) {
             $address = new Address();
             $address->attributes = $_POST['Address'];
             if ($address->save()) {
                 $model->address_id = $address->id;
             }
         }
         if (!Yii::app()->user->isGuest) {
             $model->user_id = Yii::app()->user->id;
         }
         $model->validate();
         if (Shop::module()->useWithYum && isset($_POST['register']) && ($_POST['register'] = true)) {
             if (isset($_POST['Customer']['password']) && isset($_POST['Customer']['passwordRepeat'])) {
                 if ($_POST['Customer']['password'] != $_POST['Customer']['passwordRepeat']) {
                     $model->addError('password', Shop::t('Passwords do not match'));
                 } else {
                     if ($_POST['Customer']['password'] == '') {
                         $model->addError('password', Shop::t('Password is empty'));
                     } else {
                         $user = new YumUser();
                         $profile = new YumProfile();
                         $profile->attributes = $_POST['Customer'];
                         $profile->attributes = $_POST['Address'];
                         if ($user->register(strtr($model->email, array('@' => '_', '.' => '_')), $_POST['Customer']['password'], $profile)) {
                             $user->status = YumUser::STATUS_ACTIVE;
                             $user->save(false, array('status'));
                             $model->user_id = $user->id;
                             Shop::setFlash(Shop::t('Successfully registered user'));
                         } else {
                             $model->addErrors($user->getErrors());
                             $model->addErrors($profile->getErrors());
                             Shop::setFlash(Shop::t('Error while registering user'));
                         }
                     }
                 }
             }
         }
         if (!$model->hasErrors()) {
             if ($model->save()) {
                 Yii::app()->user->setState('customer_id', $model->customer_id);
                 $this->redirect(array('//shop/order/create', 'customer' => $model->customer_id));
             }
         }
     }
     $this->render('create', array('customer' => $model, 'address' => isset($address) ? $address : new Address()));
 }
开发者ID:axetion007,项目名称:yii-shop,代码行数:57,代码来源:CustomerController.php

示例3: actionChoose

 public function actionChoose()
 {
     $this->render('choose', array('customer' => Shop::getCustomer()));
 }
开发者ID:huynhchanhuy,项目名称:yii_shopping,代码行数:4,代码来源:PaymentMethodController.php

示例4: actionConfirm

 public function actionConfirm()
 {
     Yii::app()->user->setState('order_comment', @$_POST['Order']['Comment']);
     if (isset($_POST['accept_terms']) && $_POST['accept_terms'] == 1) {
         $order = new Order();
         $customer = Shop::getCustomer();
         $cart = Shop::getCartContent();
         $order->customer_id = $customer->customer_id;
         $address = new DeliveryAddress();
         if ($customer->deliveryAddress) {
             $address->attributes = $customer->deliveryAddress->attributes;
         } else {
             $address->attributes = $customer->address->attributes;
         }
         $address->save();
         $order->delivery_address_id = $address->id;
         $address = new BillingAddress();
         if ($customer->billingAddress) {
             $address->attributes = $customer->billingAddress->attributes;
         } else {
             $address->attributes = $customer->address->attributes;
         }
         $address->save();
         $order->billing_address_id = $address->id;
         $order->ordering_date = time();
         $order->payment_method = Yii::app()->user->getState('payment_method');
         $order->shipping_method = Yii::app()->user->getState('shipping_method');
         $order->comment = Yii::app()->user->getState('order_comment');
         $order->status = 'new';
         if ($order->save()) {
             foreach ($cart as $position => $product) {
                 $position = new OrderPosition();
                 $position->order_id = $order->order_id;
                 $position->product_id = $product['product_id'];
                 $position->amount = $product['amount'];
                 $position->specifications = json_encode($product['Variations']);
                 $position->save();
             }
             Shop::mailNotification($order);
             Shop::flushCart(true);
             if (Shop::module()->payPalMethod !== false && $order->payment_method == Shop::module()->payPalMethod) {
                 $this->redirect(array(Shop::module()->payPalUrl, 'order_id' => $order->order_id));
             } else {
                 $this->redirect(Shop::module()->successAction);
             }
         }
         $this->redirect(Shop::module()->failureAction);
     } else {
         Shop::setFlash(Shop::t('Please accept our Terms and Conditions to continue'));
         $this->redirect(array('//shop/order/create'));
     }
 }
开发者ID:rinodung,项目名称:yii-shop,代码行数:52,代码来源:OrderController.php

示例5: array

$this->renderPartial('/order/waypoint', array('point' => 4));
$this->breadcrumbs = array(Shop::t('Order') => array('index'), Shop::t('New Order'));
?>

<?php 
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));
开发者ID:axetion007,项目名称:yii-shop,代码行数:30,代码来源:create.php


注:本文中的Shop::getCustomer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。