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


PHP waContact::set方法代码示例

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


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

示例1: getContact

 protected function getContact()
 {
     // Create new temporary waContact object
     $contact = new waContact(wa()->getUser()->getId());
     // Assign address with the right extension, if no extension is set
     if ($this->form->fields('address.shipping') && !$contact->get('address.shipping') && ($addresses = $contact->get('address'))) {
         $contact->set('address.shipping', $addresses[0]);
     }
     if ($this->form->fields('address.billing') && !$contact->get('address.billing') && ($addresses = $contact->get('address.shipping'))) {
         $contact->set('address.billing', $addresses[0]);
     }
     return $contact;
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:13,代码来源:shopFrontendMyProfile.action.php

示例2: execute

 /**
  * Execute step
  *
  * @return bool
  */
 public function execute()
 {
     $contact = $this->getContact();
     if (!$contact) {
         $contact = new waContact();
     }
     $data = waRequest::post('customer');
     if ($data && is_array($data)) {
         foreach ($data as $field => $value) {
             $contact->set($field, $value);
         }
     }
     $this->form = shopHelper::getCustomerForm();
     if ($shipping = $this->getSessionData('shipping') && !waRequest::post('ignore_shipping_error')) {
         $shipping_step = new shopOnestepCheckoutShipping();
         $rate = $shipping_step->getRate($shipping['id'], isset($shipping['rate_id']) ? $shipping['rate_id'] : null, $contact);
         if (!$rate || is_string($rate)) {
             // remove selected shipping method
             $this->setSessionData('shipping', null);
             /*
              $errors = array();
              $errors['all'] = sprintf(_w('We cannot ship to the specified address via %s.'), $shipping['name']);
              if ($rate) {
              $errors['all'] .= '<br> <strong>'.$rate.'</strong><br>';
              }
              $errors['all'] .= '<br> '._w('Please double-check the address above, or return to the shipping step and select another shipping option.');
              $errors['all'] .= '<input type="hidden" name="ignore_shipping_error" value="1">';
              wa()->getView()->assign('errors', $errors);
              return false;
             */
         }
     }
     if (wa()->getUser()->isAuth()) {
         $contact->save();
     } else {
         $errors = array();
         if (waRequest::post('create_user')) {
             $login = waRequest::post('login');
             if (!$login) {
                 $errors['email'][] = _ws('Required');
             }
             if (!waRequest::post('password')) {
                 $errors['password'] = _ws('Required');
             }
             $email_validator = new waEmailValidator();
             if (!$email_validator->isValid($login)) {
                 $errors['email'] = $email_validator->getErrors();
             }
             if (!$errors) {
                 $contact_model = new waContactModel();
                 if ($contact_model->getByEmail($login, true)) {
                     $errors['email'][] = _w('Email already registered');
                 }
             }
             if (!$errors) {
                 $contact->set('email', $login);
                 $contact->set('password', waRequest::post('password'));
             } else {
                 if (isset($errors['email'])) {
                     $errors['email'] = implode(', ', $errors['email']);
                 }
                 wa()->getView()->assign('errors', $errors);
                 return false;
             }
         }
         $this->setSessionData('contact', $contact);
     }
     if ($comment = waRequest::post('comment')) {
         $this->setSessionData('comment', $comment);
     }
     if (!$this->form->isValid($contact)) {
         return false;
     }
     return true;
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:80,代码来源:shopOnestepCheckoutContactinfo.class.php

示例3: execute

 public function execute()
 {
     if ($shipping_id = waRequest::post('shipping_id')) {
         if ($data = waRequest::post('customer_' . $shipping_id)) {
             $settings = wa('shop')->getConfig()->getCheckoutSettings();
             if (!isset($settings['contactinfo']) || !isset($settings['contactinfo']['fields']['address.shipping']) && !isset($settings['contactinfo']['fields']['address'])) {
                 $settings = wa('shop')->getConfig()->getCheckoutSettings(true);
             }
             $plugin = shopShipping::getPlugin(null, $shipping_id);
             $form = $this->getAddressForm($shipping_id, $plugin, $settings, array(), true);
             if (!$form->isValid()) {
                 return false;
             }
             $contact = $this->getContact();
             if (!$contact) {
                 $contact = new waContact();
             }
             if ($data && is_array($data)) {
                 foreach ($data as $field => $value) {
                     if (is_array($value) && ($old = $contact->get($field))) {
                         if (isset($old[0]['data'])) {
                             foreach ($old[0]['data'] as $k => $v) {
                                 if (!isset($value[$k])) {
                                     $value[$k] = $v;
                                 }
                             }
                         }
                     }
                     $contact->set($field, $value);
                 }
                 if (wa()->getUser()->isAuth()) {
                     $contact->save();
                 } else {
                     $this->setSessionData('contact', $contact);
                 }
             }
         }
         $rates = waRequest::post('rate_id');
         $rate_id = isset($rates[$shipping_id]) ? $rates[$shipping_id] : null;
         $rate = $this->getRate($shipping_id, $rate_id);
         if (is_string($rate)) {
             $rate = false;
         }
         $this->setSessionData('shipping', array('id' => $shipping_id, 'rate_id' => $rate_id, 'name' => $rate ? $rate['name'] : '', 'plugin' => $rate ? $rate['plugin'] : ''));
         if (!$rate) {
             return false;
         }
         if ($comment = waRequest::post('comment')) {
             $this->setSessionData('comment', $comment);
         }
         if ($shipping_params = waRequest::post('shipping_' . $shipping_id)) {
             $params = $this->getSessionData('params', array());
             $params['shipping'] = $shipping_params;
             $this->setSessionData('params', $params);
         }
         return true;
     } else {
         return false;
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:60,代码来源:shopOnestepCheckoutShipping.class.php


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