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


PHP Customer::GetCurrent方法代码示例

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


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

示例1: actionAddress

 public function actionAddress()
 {
     if (Yii::app()->user->isGuest) {
         $this->redirect($this->createUrl("/myaccount"));
     }
     $this->breadcrumbs = array(Yii::t('global', 'My Account') => $this->createUrl("/myaccount"), Yii::t('global', 'Add an address') => $this->createUrl("myaccount/address"));
     $model = new CustomerAddress();
     $model->country_id = _xls_get_conf('DEFAULT_COUNTRY', 224);
     $checkout = new CheckoutForm();
     //For logged in users we grab the current model
     $objCustomer = Customer::GetCurrent();
     $id = null;
     if (Yii::app()->getRequest()->getParam('id') != null) {
         $id = Yii::app()->getRequest()->getParam('id');
     } elseif (isset($_POST['CustomerAddress']) && isset($_POST['CustomerAddress']['id'])) {
         $id = $_POST['CustomerAddress']['id'];
     }
     $objAddress = CustomerAddress::model()->findByPk($id);
     if ($id && $objAddress instanceof CustomerAddress && $objAddress->customer_id == Yii::app()->user->id) {
         $model = $objAddress;
     }
     // collect user input data
     if (isset($_POST['CustomerAddress'])) {
         $model->setScenario('Default');
         $model->attributes = $_POST['CustomerAddress'];
         if ($model->validate()) {
             $model->customer_id = $objCustomer->id;
             if (!$model->save()) {
                 Yii::log('Error creating new customer address ' . print_r($model->getErrors(), true), 'error', 'application.' . __CLASS__ . '.' . __FUNCTION__);
             }
             if (CPropertyValue::ensureBoolean($model->makeDefaultBilling) === true) {
                 $objCustomer->default_billing_id = $model->id;
             } elseif (CPropertyValue::ensureInteger($objCustomer->default_billing_id) === CPropertyValue::ensureInteger($model->id)) {
                 $objCustomer->default_billing_id = null;
             }
             if (CPropertyValue::ensureBoolean($model->makeDefaultShipping) === true) {
                 $objCustomer->default_shipping_id = $model->id;
             } elseif (CPropertyValue::ensureInteger($objCustomer->default_shipping_id) === CPropertyValue::ensureInteger($model->id)) {
                 $objCustomer->default_shipping_id = null;
             }
             $objCustomer->save();
             ShoppingCart::displayNoTaxMessage();
             try {
                 Yii::app()->shoppingcart->setTaxCodeByDefaultShippingAddress();
             } catch (Exception $e) {
                 Yii::log('Error updating customer cart ' . $e->getMessage(), 'error', 'application.' . __CLASS__ . '.' . __FUNCTION__);
             }
             Yii::app()->shoppingcart->save();
             if (Yii::app()->request->isAjaxRequest === false) {
                 $this->redirect($this->createUrl("/myaccount"));
             }
         }
     }
     if ($id && $objCustomer->default_billing_id == $model->id) {
         $model->makeDefaultBilling = 1;
     }
     if ($id && $objCustomer->default_shipping_id == $model->id) {
         $model->makeDefaultShipping = 1;
     }
     // Added Ajax for Brooklyn2014
     if (Yii::app()->request->isAjaxRequest) {
         unset($model->password);
         $errors = $model->getErrors();
         if (empty($errors) === false) {
             $response = array('status' => 'error', 'errors' => $errors);
         } else {
             $response = array('status' => 'success', 'address' => $model);
         }
         $this->renderJSON($response);
     } else {
         $this->render('address', array('model' => $model, 'checkout' => $checkout));
     }
 }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:73,代码来源:MyaccountController.php

示例2: customer

 public function customer()
 {
     return Customer::GetCurrent();
 }
开发者ID:hjlan,项目名称:webstore,代码行数:4,代码来源:WsExtension.php

示例3: actionIndex

 /**
  * Checkout as a guest or as an existing user
  *
  * @return void
  */
 public function actionIndex()
 {
     $this->checkoutForm = MultiCheckoutForm::loadFromSessionOrNew();
     // did user leave checkout and come back?
     $returnRoute = $this->checkoutForm->getCheckoutPoint();
     if (is_null($returnRoute) === false && isset($_GET['showLogin']) === false) {
         // send user to correct checkout point
         $this->redirect($this->createAbsoluteUrl($returnRoute));
     }
     // if the user is already logged in take them straight to shipping
     if (!Yii::app()->user->isGuest) {
         $objCustomer = Customer::GetCurrent();
         $this->checkoutForm->contactEmail = $this->checkoutForm->contactEmail_repeat = $objCustomer->email;
         $this->checkoutForm->saveFormToSession();
         // set cart customer if missing
         $objCart = Yii::app()->shoppingcart;
         if ($objCart->customer_id !== $objCustomer->id) {
             $objCart->customer_id = $objCustomer->id;
             $objCart->save();
         }
         $this->redirect($this->createAbsoluteUrl('/checkout/shippingaddress'));
     }
     $this->publishJS('index');
     $this->layout = '/layouts/checkout-column2';
     $model = new LoginForm();
     $showLoginPasswordField = false;
     // collect user input data
     if (isset($_POST['LoginForm'])) {
         $model->attributes = $_POST['LoginForm'];
         // validate user input and continue if valid
         if ($model->guest == 0) {
             $showLoginPasswordField = true;
             $success = $model->validate() && $model->login();
         } else {
             $model->setScenario('Guest');
             $success = $model->validate();
         }
         if ($success) {
             $this->checkoutForm->passedScenario = $model->getScenario();
             $this->checkoutForm->contactEmail = strtolower($model->email);
             $this->checkoutForm->contactEmail_repeat = strtolower($model->email);
             $this->checkoutForm->saveFormToSession();
             if ($this->checkoutForm->validate()) {
                 if ($model->guest) {
                     $this->redirect($this->createAbsoluteUrl('/checkout/shipping'));
                 } else {
                     $this->redirect($this->createAbsoluteUrl("/checkout/shippingaddress"));
                 }
             }
         }
         $this->checkoutForm->addErrors($model->getErrors());
     }
     $blnShowLogin = false;
     if (isset($_SESSION['checkoutform.cache'])) {
         $model->email = $_SESSION['checkoutform.cache']['contactEmail'];
     }
     if (isset($_GET['showLogin'])) {
         $blnShowLogin = $_GET['showLogin'];
     }
     // display the login form
     $this->render('index', array('model' => $model, 'error' => $this->formatErrors(), 'blnShowLogin' => $blnShowLogin, 'showLoginPasswordField' => $showLoginPasswordField));
 }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:67,代码来源:CheckoutController.php

示例4: getQuantityPrices

 /**
  * Return an array of the applicable ProductQtyPrice objects
  * @return array
  */
 protected function getQuantityPrices()
 {
     $customer = Customer::GetCurrent();
     $intCustomerLevel = 1;
     $arrPrices = false;
     if ($customer && !is_null($customer->pricing_level)) {
         $intCustomerLevel = $customer->pricing_level;
     }
     $arrPriceArray = $this->productQtyPricings;
     foreach ($arrPriceArray as $value) {
         if ($value->pricing_level == $intCustomerLevel && $value->qty > 0) {
             $arrPrices[] = $value;
         }
     }
     return $arrPrices;
 }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:20,代码来源:Product.php

示例5: displayNoTaxMessage

 /**
  * Display a message if a customer's shipping address is in no-tax destination in tax-inclusive mode.
  *
  * @return bool true if no-tax message will be displayed.
  */
 public static function displayNoTaxMessage()
 {
     // If the store is tax exclusive, just return, because price modes don't switch with
     // tax exlusive stores.
     if (CPropertyValue::ensureBoolean(Yii::app()->params['TAX_INCLUSIVE_PRICING']) === false) {
         return false;
     }
     $objCustomer = Customer::GetCurrent();
     if ($objCustomer instanceof Customer === false) {
         return false;
     }
     if ($objCustomer->defaultShippingIsNoTax() === true) {
         Yii::app()->user->setFlash('warning', Yii::t('global', 'Note: Because of your default shipping address, prices will be displayed without tax.'));
         return true;
     }
     return false;
 }
开发者ID:hjlan,项目名称:webstore,代码行数:22,代码来源:ShoppingCart.php

示例6: fillFieldsFromPreselect

 /**
  * If the shopper has chosen an address from the address book, copy the values to the
  * relevant address fields since they're needed for shipping and payment calculations
  *
  * @return void
  */
 public function fillFieldsFromPreselect()
 {
     $arrObjAddresses = CustomerAddress::getActiveAddresses();
     $objCustomer = Customer::GetCurrent();
     if ($this->intShippingAddress > 0) {
         // We've picked a preset to ship to, so grab that info from the db.
         if (Yii::app()->shoppingcart->HasShippableGift) {
             $objAddresses = array_merge($arrObjAddresses, Yii::app()->shoppingcart->GiftAddress);
         }
         foreach ($arrObjAddresses as $objAddress) {
             if ($objAddress->id != $this->intShippingAddress) {
                 continue;
             }
             $this->shippingFirstName = $objAddress->first_name;
             $this->shippingLastName = $objAddress->last_name;
             $this->shippingAddress1 = $objAddress->address1;
             $this->shippingAddress2 = $objAddress->address2;
             $this->shippingCity = $objAddress->city;
             $this->shippingState = $objAddress->state_id;
             $this->shippingPostal = $objAddress->postal;
             $this->shippingCountry = $objAddress->country_id;
             $this->shippingResidential = $objAddress->residential;
             if (empty($objAddress->phone) === false) {
                 $this->shippingPhone = $objAddress->phone;
             }
             break;
         }
     }
     if ($this->billingSameAsShipping == 1) {
         $this->billingAddress1 = $this->shippingAddress1;
         $this->billingAddress2 = $this->shippingAddress2;
         $this->billingCity = $this->shippingCity;
         $this->billingCountry = $this->shippingCountry;
         $this->billingCountryCode = $this->shippingCountryCode;
         $this->billingState = $this->shippingState;
         $this->billingStateCode = $this->shippingStateCode;
         $this->billingPostal = $this->shippingPostal;
         $this->billingResidential = $this->shippingResidential;
     } elseif ($this->intBillingAddress > 0) {
         // end-user has selected an existing address
         $objAddress = CustomerAddress::findCustomerAddress($objCustomer->id, $this->intBillingAddress);
         $this->billingAddress1 = $objAddress->address1;
         $this->billingAddress2 = $objAddress->address2;
         $this->billingCity = $objAddress->city;
         $this->billingState = $objAddress->state_id;
         $this->billingPostal = $objAddress->postal;
         $this->billingCountry = $objAddress->country_id;
         $this->billingResidential = $objAddress->residential;
     }
     if ($objCustomer instanceof Customer) {
         $this->contactFirstName = $objCustomer->first_name;
         $this->contactLastName = $objCustomer->last_name;
         $this->contactPhone = $objCustomer->mainphone;
         $this->contactEmail = $objCustomer->email;
     }
 }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:62,代码来源:BaseCheckoutForm.php

示例7: actionContact

 /**
  * Displays the contact page
  */
 public function actionContact()
 {
     $model = CustomPage::LoadByRequestUrl('contact-us');
     $this->pageTitle = $model->PageTitle;
     $this->pageDescription = $model->meta_description;
     $this->breadcrumbs = array($model->title => $model->RequestUrl);
     $this->layout = "//layouts/column" . $model->column_template;
     $ContactForm = new ContactForm();
     if (isset($_POST['ContactForm'])) {
         $ContactForm->attributes = $_POST['ContactForm'];
         if ($ContactForm->validate()) {
             $objEmail = new EmailQueue();
             if (!Yii::app()->user->isGuest) {
                 $objCustomer = Customer::GetCurrent();
                 $objEmail->customer_id = $objCustomer->id;
                 $ContactForm->fromName = $objCustomer->mainname;
                 $ContactForm->fromEmail = $objCustomer->email;
             }
             $strHtmlBody = $this->renderPartial('/mail/_contactform', array('model' => $ContactForm), true);
             $strSubject = Yii::t('email', 'Contact Us:') . $ContactForm->contactSubject;
             $objEmail->htmlbody = $strHtmlBody;
             $objEmail->subject = $strSubject;
             $orderEmail = _xls_get_conf('ORDER_FROM', '');
             $objEmail->to = empty($orderEmail) ? _xls_get_conf('EMAIL_FROM') : $orderEmail;
             $objHtml = new HtmlToText();
             //If we get back false, it means conversion failed which 99.9% of the time means improper HTML.
             $strPlain = $objHtml->convert_html_to_text($strHtmlBody);
             if ($strPlain !== false) {
                 $objEmail->plainbody = $strPlain;
             }
             if (!$objEmail->save()) {
                 Yii::log("Error creating email " . print_r($objEmail, true) . " " . print_r($objEmail->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
             }
             Yii::app()->user->setFlash('success', Yii::t('email', 'Message sent. Thank you for contacting us. We will respond to you as soon as possible.'));
             //Attempt to use an AJAX call to send the email. If it doesn't work, the Download process will catch it anyway.
             $jsScript = "\$.ajax({url:\"" . CController::createUrl('site/sendemail', array("id" => $objEmail->id)) . "\"});";
             Yii::app()->clientScript->registerScript('sendemail', $jsScript, CClientScript::POS_READY);
         } else {
             Yii::app()->user->setFlash('error', Yii::t('cart', 'Please check your form for errors.'));
             if (YII_DEBUG) {
                 Yii::app()->user->setFlash('error', print_r($ContactForm->getErrors(), true));
             }
         }
     }
     if (!Yii::app()->user->isGuest) {
         $objCustomer = Customer::GetCurrent();
         $ContactForm->fromName = $objCustomer->mainname;
         $ContactForm->fromEmail = $objCustomer->email;
     }
     $this->canonicalUrl = $model->canonicalUrl;
     $this->render('contact', array('ContactForm' => $ContactForm, 'model' => $model));
 }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:55,代码来源:CustompageController.php

示例8: actionCheckout


//.........这里部分代码省略.........
                    $objAddress->country_id = $model->shippingCountry;
                    $objAddress->residential = $model->shippingResidential;
                    if (!$objAddress->save()) {
                        Yii::app()->user->setFlash('error', print_r($objAddress->getErrors(), true));
                        Yii::log("Error creating CustomerAddress Shipping " . print_r($objAddress->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
                        $this->refresh();
                    }
                    $objCart->shipaddress_id = $model->intShippingAddress = $objAddress->id;
                    unset($objAddress);
                }
                if ($objCustomer instanceof Customer) {
                    if (is_null($objCustomer->default_shipping_id)) {
                        $objCustomer->default_shipping_id = $model->intShippingAddress;
                        $objCustomer->save();
                        try {
                            $objCart->setTaxCodeByDefaultShippingAddress();
                        } catch (Exception $e) {
                            Yii::log("Error updating customer cart " . $e->getMessage(), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
                        }
                        $objCart->recalculateAndSave();
                    }
                }
                // If billing address is value, then choose that otherwise enter
                // new billing address and assign value.
                if ($model->intBillingAddress) {
                    $objCart->billaddress_id = $model->intBillingAddress;
                } elseif ($model->billingSameAsShipping) {
                    $objCart->billaddress_id = $model->intBillingAddress = $model->intShippingAddress;
                } else {
                    if (empty($model->billingLabel)) {
                        $model->billingLabel = Yii::t('checkout', 'Unlabeled address');
                    }
                    if (!Yii::app()->user->isGuest) {
                        $objCustomer = Customer::GetCurrent();
                        if ($objCustomer instanceof Customer) {
                            $model->contactFirstName = $objCustomer->first_name;
                            $model->contactLastName = $objCustomer->last_name;
                        }
                    }
                    $objAddress = new CustomerAddress();
                    $objAddress->customer_id = $intCustomerId;
                    $objAddress->address_label = $model->billingLabel;
                    $objAddress->first_name = $model->contactFirstName;
                    $objAddress->last_name = $model->contactLastName;
                    $objAddress->company = $model->contactCompany;
                    $objAddress->address1 = $model->billingAddress1;
                    $objAddress->address2 = $model->billingAddress2;
                    $objAddress->city = $model->billingCity;
                    $objAddress->state_id = $model->billingState;
                    $objAddress->postal = $model->billingPostal;
                    $objAddress->country_id = $model->billingCountry;
                    $objAddress->phone = $model->contactPhone;
                    $objAddress->residential = $model->billingResidential;
                    if (!$objAddress->save()) {
                        Yii::app()->user->setFlash('error', print_r($objAddress->getErrors(), true));
                        Yii::log("Error creating CustomerAddress Billing " . print_r($objAddress->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
                        $this->refresh();
                    }
                    $objCart->billaddress_id = $model->intBillingAddress = $objAddress->id;
                    unset($objAddress);
                }
                if ($objCustomer instanceof Customer) {
                    if (is_null($objCustomer->default_billing_id)) {
                        $objCustomer->default_billing_id = $model->intBillingAddress;
                        $objCustomer->save();
                    }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:67,代码来源:CartController.php


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