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


PHP Customer::add方法代码示例

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


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

示例1: initContent

    /**
     * @see FrontController::initContent()
     */
    public function initContent()
    {
        parent::initContent();
        if ($this->context->customer->isLogged()) {
            Tools::redirect('index.php?controller=my-account');
        }
        $fb_connect_appid = Configuration::get('FB_CONNECT_APPID');
        $fb_connect_appkey = Configuration::get('FB_CONNECT_APPKEY');
        $this->redirect_uri = $this->context->link->getModuleLink('fbconnect_psb', 'registration', array('done' => 1), TRUE, $this->context->language->id);
        require_once _PS_ROOT_DIR_ . '/modules/fbconnect_psb/fb_sdk/facebook.php';
        $facebook = new Facebook(array('appId' => $fb_connect_appid, 'secret' => $fb_connect_appkey));
        // Get User ID
        $user = $facebook->getUser();
        // We may or may not have this data based on whether the user is logged in.
        //
        // If we have a $user id here, it means we know the user is logged into
        // Facebook, but we don't know if the access token is valid. An access
        // token is invalid if the user logged out of Facebook.
        if ($user) {
            try {
                // Proceed knowing you have a logged in user who's authenticated.
                $fb_user_profile = $facebook->api('/me');
            } catch (FacebookApiException $e) {
                //die('Error: '.$e);
                error_log($e);
                $user = null;
            }
        } else {
            // Get new Access tokens
            Tools::redirect($facebook->getLoginUrl(array('scope' => 'email')));
        }
        // if user's FB account is linked than log the user in
        if (isset($fb_user_profile['id'])) {
            $sql = 'SELECT `id_customer`
				FROM `' . _DB_PREFIX_ . 'customer_profile_connect`
				WHERE `facebook_id` = \'' . (int) $fb_user_profile['id'] . '\'' . Shop::addSqlRestriction(Shop::SHARE_CUSTOMER);
            if (Db::getInstance()->getValue($sql)) {
                Tools::redirect($this->context->link->getModuleLink('fbconnect_psb', 'login', array(), TRUE, $this->context->language->id));
            }
        }
        if (Tools::getValue('done')) {
            $response = $facebook->getSignedRequest($_REQUEST['signed_request']);
            $reg_metadata_fields = '[{"name":"name"},{"name":"first_name"},{"name":"last_name"},{"name":"email"},{"name":"password"},{"name":"birthday"},{"name":"gender"}]';
            $reg_metadata_fields_clean = preg_replace('/\\s+/', '', $reg_metadata_fields);
            $response_metadata_fields_clean = preg_replace('/\\s+/', '', $response['registration_metadata']['fields']);
            if (strcmp($reg_metadata_fields_clean, $response_metadata_fields_clean) != 0) {
                $this->errors[] = Tools::displayError('registration metadata fields not valid');
            }
            $response_email = trim($response['registration']['email']);
            if (empty($response_email)) {
                $this->errors[] = Tools::displayError('An email address required.');
            } else {
                if (!Validate::isEmail($response_email)) {
                    $this->errors[] = Tools::displayError('Invalid email address.');
                } else {
                    if (Customer::customerExists($response_email)) {
                        // Need to clean up the code here most of it is from
                        // IDFBCon_v.0.2 (Chandra R. Atmaja <chandra.r.atmaja@gmail.com>)
                        // Someone has already registered with this e-mail address
                        // This will link the 1st existing email/account on site with Facebook
                        // and log the user in to the account. Is this safe?
                        $customer = new Customer();
                        $authentication = $customer->getByEmail($response['registration']['email']);
                        // This is done to see if a existing users try's to re-registrar
                        $sql = 'SELECT `facebook_id`
					FROM `' . _DB_PREFIX_ . 'customer_profile_connect`
					WHERE `id_customer` = \'' . (int) $customer->id . '\' ' . Shop::addSqlRestriction(Shop::SHARE_CUSTOMER);
                        $customer_fb_id = Db::getInstance()->getValue($sql);
                        if ($customer_fb_id) {
                            if ($customer_fb_id == (int) $response['user_id']) {
                                Tools::redirect($this->context->link->getModuleLink('fbconnect_psb', 'login', array(), false, $this->context->language->id));
                            } else {
                                $this->errors[] = Tools::displayError('An error occurred while linking your Facebook account.');
                            }
                        } else {
                            if (Db::getInstance()->insert('customer_profile_connect', array('id_customer' => (int) $customer->id, 'facebook_id' => (int) $response['user_id']))) {
                                $this->errors[] = Tools::displayError('an error occurred while linking your Facebook account.');
                            }
                            $customer->active = 1;
                            $customer->deleted = 0;
                            $this->context->cookie->id_customer = intval($customer->id);
                            $this->context->cookie->customer_lastname = $customer->lastname;
                            $this->context->cookie->customer_firstname = $customer->firstname;
                            $this->context->cookie->logged = 1;
                            $this->context->cookie->passwd = $customer->passwd;
                            $this->context->cookie->email = $customer->email;
                            if (Configuration::get('PS_CART_FOLLOWING') and (empty($this->context->cookie->id_cart) or Cart::getNbProducts($this->context->cookie->id_cart) == 0)) {
                                $this->context->cookie->id_cart = intval(Cart::lastNoneOrderedCart(intval($customer->id)));
                            }
                            Module::hookExec('authentication');
                            if ($back = Tools::getValue('back')) {
                                Tools::redirect($back);
                            }
                            Tools::redirect('index.php?controller=my-account');
                        }
                    }
                }
//.........这里部分代码省略.........
开发者ID:codingang,项目名称:PrestaShop-modules-fbConnect_psb,代码行数:101,代码来源:registration.php

示例2: create

 public function create()
 {
     if ($this->f3->exists('POST.create')) {
         $user = new Customer($this->db);
         $user->add();
         $this->f3->reroute('/customer');
     } else {
         $this->f3->set('page_head', 'Create Customer');
         $this->f3->set('view', 'customer/create.htm');
     }
     echo Template::instance()->render('layout.htm');
 }
开发者ID:srccn,项目名称:f3,代码行数:12,代码来源:CustomerController.php

示例3: helloWorld

 public function helloWorld()
 {
     $obj = new Customer();
     $obj->fname = 'Monika';
     $obj->lname = "x' or 'x'='x";
     $obj->email = 'monika.w@cisinlabs.com';
     $obj->password = md5('123456');
     $obj->date = date('Y-m-d H:i:s');
     try {
         $return = $obj->add();
     } catch (Exception $e) {
         die($e->getMessage());
     }
 }
开发者ID:agwan786,项目名称:framework,代码行数:14,代码来源:welcome.php

示例4: createCustomer

 /**
  * Create virtual customer to associate address for country selection
  *
  * @return bool
  */
 private function createCustomer()
 {
     $customer = new Customer();
     $customer->email = 'shipping_estimation@prestashop_virtual.com';
     $customer->lastname = 'Shipping';
     $customer->firstname = 'Estimation';
     $customer->deleted = 1;
     // Keep it Hidden
     $customer->passwd = Tools::encrypt(Tools::passwdGen());
     if ($customer->add()) {
         Configuration::updateValue(CarrierCompare::VIRTUAL_CUSTOMER, $customer->id);
         return true;
     }
     return false;
 }
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:20,代码来源:carriercompare.php

示例5: action_add_customer

 public function action_add_customer()
 {
     if (count($_POST)) {
         $post = new Validation($_POST);
         $post->filter('trim');
         if ($post->validate()) {
             $customer_id = Customer::add($post->as_array());
             $this->add_message('Customer ' . $post->get('name') . ' added with ID #' . $customer_id);
         } else {
             $this->add_error('Fix errors and try again');
             $this->add_form_errors($post->errors());
             $this->set_formdata($post->as_array());
         }
     }
 }
开发者ID:rockymontana,项目名称:larvconomy,代码行数:15,代码来源:customers.php

示例6: customer_add

function customer_add()
{
    $customer = new Customer();
    $customer->name = isset($_POST['name']) ? $_POST['name'] : "";
    $customer->address = isset($_POST['address']) ? $_POST['address'] : "";
    $customer->phone = isset($_POST['phone']) ? $_POST['phone'] : "";
    $customer->cell = isset($_POST['cell']) ? $_POST['cell'] : "";
    $customer->active = isset($_POST['active']) ? $_POST['active'] : 0;
    $customer->email = isset($_POST['email']) ? $_POST['email'] : "";
    $customer->nit = isset($_POST['nit']) ? $_POST['nit'] : "";
    if ($customer->add()) {
        $params = array("customer" => $customer->id);
        header("location: " . Forms::getLink(FORM_CUSTOMER_DETAIL, $params));
        exit;
    }
    return false;
}
开发者ID:BackupTheBerlios,项目名称:rinventory-svn,代码行数:17,代码来源:customer.php

示例7: register

 public function register()
 {
     if (post('register')) {
         $pengguna = ['username' => post('username'), 'email' => post('email'), 'level' => 0, 'aktif' => 1];
         $pelanggan = ['nama_lengkap' => post('nama'), 'alamat' => post('alamat'), 'kota' => post('kota'), 'telp' => post('telp')];
         if (post('password') == post('passconf')) {
             $pengguna['password'] = md5(post('password'));
         }
         if ($userId = User::add($pengguna)) {
             $pelanggan['id_pengguna'] = $userId;
             if (Customer::add($pelanggan)) {
                 set_alert('success', 'Registrasi berhasil, silahkan login ke akun yang baru saja anda buat');
                 redirect('login');
             } else {
                 set_alert('error', 'Maaf registrasi gagal');
                 redirect('register');
             }
         }
     }
     return $this->render('form-register', ['heading' => 'Silahkan register']);
 }
开发者ID:gaiius,项目名称:tokonlen,代码行数:21,代码来源:function.php

示例8: submitAccount

function submitAccount()
{
    global $cookie, $errors, $smarty;
    $email = Tools::getValue('email');
    if (empty($email) or !Validate::isEmail($email)) {
        $errors[] = Tools::displayError('e-mail not valid');
    } elseif (!Validate::isPasswd(Tools::getValue('passwd'))) {
        $errors[] = Tools::displayError('invalid password');
    } elseif (Customer::customerExists($email)) {
        $errors[] = Tools::displayError('someone has already registered with this e-mail address');
    } elseif (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) and !(Tools::getValue('months') == '' and Tools::getValue('days') == '' and Tools::getValue('years') == '')) {
        $errors[] = Tools::displayError('invalid birthday');
    } else {
        $customer = new Customer();
        if (Tools::isSubmit('newsletter')) {
            $customer->ip_registration_newsletter = pSQL(Tools::getRemoteAddr());
            $customer->newsletter_date_add = pSQL(date('Y-m-d h:i:s'));
        }
        $customer->birthday = empty($_POST['years']) ? '' : (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
        /* Customer and address, same fields, caching data */
        $errors = $customer->validateControler();
        $address = new Address();
        $address->id_customer = 1;
        $errors = array_unique(array_merge($errors, $address->validateControler()));
        if (!sizeof($errors)) {
            $customer->active = 1;
            if (!$customer->add()) {
                $errors[] = Tools::displayError('an error occurred while creating your account');
            } else {
                $address->id_customer = (int) $customer->id;
                if (!$address->add()) {
                    $errors[] = Tools::displayError('an error occurred while creating your address');
                } else {
                    if (Mail::Send((int) $cookie->id_lang, 'account', Mail::l('Welcome!', (int) $cookie->id_lang), array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{passwd}' => Tools::getValue('passwd')), $customer->email, $customer->firstname . ' ' . $customer->lastname)) {
                        $smarty->assign('confirmation', 1);
                    }
                    $cookie->id_customer = (int) $customer->id;
                    $cookie->customer_lastname = $customer->lastname;
                    $cookie->customer_firstname = $customer->firstname;
                    $cookie->passwd = $customer->passwd;
                    $cookie->logged = 1;
                    $cookie->email = $customer->email;
                    Module::hookExec('createAccount', array('_POST' => $_POST, 'newCustomer' => $customer));
                    // Next !
                    $payerID = strval(Tools::getValue('payerID'));
                    displayProcess($payerID);
                }
            }
        }
    }
}
开发者ID:greench,项目名称:prestashop,代码行数:51,代码来源:submit.php

示例9: _expressCheckout

 /**
  * When the customer is back from PayPal after filling his/her credit card info or credentials, this function is preparing the order
  * PayPal is providing us with the customer info (E-mail address, billing address) and we are trying to find a matching customer in the Shop database.
  * If no customer is found, we create a new one and we simulate a logged customer session.
  * Eventually it will redirect the customer to the "Shipping" step/page of the order process
  */
 private function _expressCheckout()
 {
     /* We need to double-check that the token provided by PayPal is the one expected */
     $result = $this->paypal_usa->postToPayPal('GetExpressCheckoutDetails', '&TOKEN=' . urlencode(Tools::getValue('token')));
     if ((strtoupper($result['ACK']) == 'SUCCESS' || strtoupper($result['ACK']) == 'SUCCESSWITHWARNING') && $result['TOKEN'] == Tools::getValue('token') && $result['PAYERID'] == Tools::getValue('PayerID')) {
         /* Checks if a customer already exists for this e-mail address */
         if (Validate::isEmail($result['EMAIL'])) {
             $customer = new Customer();
             $customer->getByEmail($result['EMAIL']);
         }
         /* If the customer does not exist yet, create a new one */
         if (!Validate::isLoadedObject($customer)) {
             $customer = new Customer();
             $customer->email = $result['EMAIL'];
             $customer->firstname = $result['FIRSTNAME'];
             $customer->lastname = $result['LASTNAME'];
             $customer->passwd = Tools::encrypt(Tools::passwdGen());
             $customer->add();
         }
         /* Look for an existing PayPal address for this customer */
         $addresses = $customer->getAddresses((int) Configuration::get('PS_LANG_DEFAULT'));
         foreach ($addresses as $address) {
             if ($address['alias'] == 'PayPal') {
                 $id_address = (int) $address['id_address'];
                 break;
             }
         }
         /* Create or update a PayPal address for this customer */
         $address = new Address(isset($id_address) ? (int) $id_address : 0);
         $address->id_customer = (int) $customer->id;
         $address->id_country = (int) Country::getByIso($result['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE']);
         $address->id_state = (int) State::getIdByIso($result['PAYMENTREQUEST_0_SHIPTOSTATE'], (int) $address->id_country);
         $address->alias = 'PayPal';
         $address->lastname = substr($result['PAYMENTREQUEST_0_SHIPTONAME'], 0, strpos($result['PAYMENTREQUEST_0_SHIPTONAME'], ' '));
         $address->firstname = substr($result['PAYMENTREQUEST_0_SHIPTONAME'], strpos($result['PAYMENTREQUEST_0_SHIPTONAME'], ' '), strlen($result['PAYMENTREQUEST_0_SHIPTONAME']) - strlen($address->lastname));
         $address->address1 = $result['PAYMENTREQUEST_0_SHIPTOSTREET'];
         if ($result['PAYMENTREQUEST_0_SHIPTOSTREET2'] != '') {
             $address->address2 = $result['PAYMENTREQUEST_0_SHIPTOSTREET2'];
         }
         $address->city = $result['PAYMENTREQUEST_0_SHIPTOCITY'];
         $address->postcode = $result['PAYMENTREQUEST_0_SHIPTOZIP'];
         $address->save();
         /* Update the cart billing and delivery addresses */
         $this->context->cart->id_address_delivery = (int) $address->id;
         $this->context->cart->id_address_invoice = (int) $address->id;
         $this->context->cart->update();
         /* Update the customer cookie to simulate a logged-in session */
         $this->context->cookie->id_customer = (int) $customer->id;
         $this->context->cookie->customer_lastname = $customer->lastname;
         $this->context->cookie->customer_firstname = $customer->firstname;
         $this->context->cookie->passwd = $customer->passwd;
         $this->context->cookie->email = $customer->email;
         $this->context->cookie->is_guest = $customer->isGuest();
         $this->context->cookie->logged = 1;
         /* Save the Payer ID and Checkout token for later use (during the payment step/page) */
         $this->context->cookie->paypal_express_checkout_token = $result['TOKEN'];
         $this->context->cookie->paypal_express_checkout_payer_id = $result['PAYERID'];
         if (_PS_VERSION_ < '1.5') {
             Module::hookExec('authentication');
         } else {
             Hook::exec('authentication');
         }
         /* Redirect the use to the "Shipping" step/page of the order process */
         Tools::redirectLink($this->context->link->getPageLink('order.php', false, null, array('step' => '3')));
         exit;
     } else {
         foreach ($result as $key => $val) {
             $result[$key] = urldecode($val);
         }
         $this->context->smarty->assign('paypal_usa_errors', $result);
         $this->setTemplate('express-checkout-messages.tpl');
     }
 }
开发者ID:juniorhq88,项目名称:PrestaShop-modules,代码行数:79,代码来源:expresscheckout.php

示例10: handleBuyerRegisterUserPassword

 public function handleBuyerRegisterUserPassword($metadata, $request, $encoder)
 {
     // prepare the fields inside the POST (so we can use Prestashop's validateController)
     unset($_POST['email']);
     if (isset($request['Buyer']['Username'])) {
         $_POST['email'] = $request['Buyer']['Username'];
     }
     unset($_POST['passwd']);
     if (isset($request['Buyer']['Password'])) {
         $_POST['passwd'] = $request['Buyer']['Password'];
     }
     unset($_POST['firstname']);
     if (isset($request['Buyer']['FirstName'])) {
         $_POST['firstname'] = $request['Buyer']['FirstName'];
     }
     unset($_POST['lastname']);
     if (isset($request['Buyer']['LastName'])) {
         $_POST['lastname'] = $request['Buyer']['LastName'];
     }
     // verify fields are valid
     $customer = new Customer();
     if (_PS_VERSION_ < '1.5') {
         $errors = $customer->validateControler();
     } else {
         $errors = $customer->validateController();
     }
     if (is_array($errors) && count($errors) > 0) {
         CartAPI_Helpers::dieOnError($encoder, 'RegisterNotAuthorized', CartAPI_Handlers_Helpers::removeHtmlTags($errors[0]));
     }
     // make sure the customer doesn't already exist
     if (Customer::customerExists($_POST['email'])) {
         CartAPI_Helpers::dieOnError($encoder, 'RegisterNotAuthorized', CartAPI_Handlers_Helpers::removeHtmlTags(Tools::displayError('An account is already registered with this e-mail, please fill in the password or request a new one.')));
     }
     // add the new user
     $customer->active = 1;
     if (property_exists('Customer', 'is_guest')) {
         $customer->is_guest = 0;
     }
     if (!$customer->add()) {
         CartAPI_Helpers::dieOnError($encoder, 'RegisterNotAuthorized', CartAPI_Handlers_Helpers::removeHtmlTags(Tools::displayError('An error occurred while creating your account.')));
     }
     // see if we need to login too
     if (!isset($request['Login']) || $request['Login'] == 'true') {
         $cookie = $this->syncCookie($customer);
         // run the after login events, actually don't since prestashop AuthController doesn't do it
         // $this->afterBuyerLogin($customer);
     }
     // run the after register events
     $this->afterBuyerRegister($customer, $request['Buyer']);
 }
开发者ID:madeny,项目名称:cartapi-plugin-prestashop,代码行数:50,代码来源:Login.php

示例11: orders

 public function orders($do = '', $id = '')
 {
     $this->data['heading'] = 'Administrasi: Pembelian';
     switch ($do) {
         case 'form':
             if (post('submit')) {
                 $userKey = User::primary();
                 $customerKey = Customer::primary();
                 $productKey = Product::primary();
                 $order = [$userKey => 1, 'status' => post('status') ?: 0];
                 if ($tanggal = post('tanggal')) {
                     $order['tanggal'] = formatTanggal($tanggal, 'Y-m-d');
                 } else {
                     $order['tanggal'] = date('Y-m-d');
                 }
                 try {
                     $upload = new Upload('pembayaran');
                     $order['pembayaran'] = $upload->doUpload();
                 } catch (Exception $e) {
                     setAlert('error', $e->getMessage());
                 }
                 if ($id_pelanggan = post($customerKey)) {
                     $order[$customerKey] = $id_pelanggan;
                 } else {
                     $pengguna = ['username' => post('username'), 'email' => post('email'), 'level' => 0, 'aktif' => 1];
                     $pelanggan = ['nama_lengkap' => post('nama_lengkap'), 'alamat' => post('alamat'), 'kota' => post('kota'), 'telp' => post('telp')];
                     if ($password = post('password') and $password == post('passconf')) {
                         $pengguna['password'] = $password;
                     }
                     if ($id_pengguna = User::add($pengguna)) {
                         $pelanggan[$userKey] = $id_pengguna;
                     }
                     if ($id_pengguna and $id_pelanggan = Customer::add($pelanggan)) {
                         $order[$customerKey] = $id_pelanggan;
                     }
                 }
                 if ($produks = post($productKey)) {
                     $produk_qty = post('produk_qty');
                     $produk_arr = [];
                     foreach ($produks as $i => $produk_id) {
                         $produk_arr[$produk_id] = $produk_qty[$i];
                     }
                     $order['produk'] = serialize($produk_arr);
                 }
                 if ($ongkir = post('ongkir') and $kurir = post('kurir')) {
                     $order['ongkir'] = $ongkir;
                     $order['kurir'] = $kurir;
                 }
                 if ($belanja = post('belanja') and $total = post('total')) {
                     $order['belanja'] = $belanja;
                     $order['total'] = $total;
                 }
                 if ($order['status'] === 0) {
                     $order['potongan'] = post('potongan') ?: 0;
                     $order['bayar'] = post('bayar') ?: 0;
                     $order['kembali'] = post('kembali') ?: 0;
                     if ($order['kembali'] < 0) {
                         $order['kembali'] = 0;
                     }
                     if ($order['bayar'] > 0) {
                         $order['status'] = 1;
                     }
                 }
                 if ($resi = post('resi')) {
                     $order['resi'] = $resi;
                 }
                 if (Order::save($order, $id)) {
                     if ($id) {
                         setAlert('success', 'Berhasil memperbarui data order <b>' . $order['nama'] . '</b>');
                     } else {
                         setAlert('success', 'Berhasil menambahkan order <b>' . $order['nama'] . '</b>');
                     }
                     return redirect('admin-shop/orders');
                 }
                 setAlert('error', 'Terjadi kesalahan dalam penyimpanan order');
                 return redirect($this->uri->path());
             }
             $order_data = $id ? Order::show($id)->fetchOne() : [];
             if (!User::is('admin') and ($order_data and $order_data->{$customerKey} != User::current($customerKey))) {
                 return redirect('admin-shop/orders');
             }
             $this->data['data'] = $order_data;
             return $this->render('order-form', $this->data);
             break;
         case 'delete':
             if (Order::del([Order::primary() => $id])) {
                 setAlert('success', 'Order berhasil terhapus');
             } else {
                 setAlert('error', 'Terjadi kesalahan dalam penghapusan order');
             }
             return redirect('admin-shop/orders');
             break;
         default:
             $filter = !User::is('admin') ? [Customer::primary() => User::current('id_pelanggan')] : [];
             $this->data['data'] = Order::show($filter, get('sort'));
             return $this->render('order-table', $this->data);
             break;
     }
 }
开发者ID:tommyputranto,项目名称:tokonlen,代码行数:99,代码来源:AdminShop.class.php

示例12: getOrAddCustomer

    public function getOrAddCustomer($ebay_profile)
    {
        $id_customer = (int) Db::getInstance()->getValue('SELECT `id_customer`
			FROM `' . _DB_PREFIX_ . 'customer`
			WHERE `active` = 1
			AND `email` = \'' . pSQL($this->email) . '\'
			AND `id_shop` = ' . (int) $ebay_profile->id_shop . '
			AND `deleted` = 0' . (Tools::substr(_PS_VERSION_, 0, 3) == '1.3' ? '' : ' AND `is_guest` = 0'));
        $format = new TotFormat();
        // Add customer if he doesn't exist
        //if ($id_customer < 1) RAPH
        if (!$id_customer) {
            $customer = new Customer();
            $customer->id_gender = 0;
            $customer->id_default_group = 1;
            $customer->secure_key = md5(uniqid(rand(), true));
            $customer->email = $format->formatEmail($this->email);
            $customer->passwd = md5(_COOKIE_KEY_ . rand());
            $customer->last_passwd_gen = date('Y-m-d H:i:s');
            $customer->newsletter = 0;
            $customer->lastname = $format->formatName(EbayOrder::_formatFamilyName($this->familyname));
            $customer->firstname = $format->formatName($this->firstname);
            $customer->active = 1;
            $customer->id_shop = (int) $ebay_profile->id_shop;
            $res = $customer->add();
            $this->_writeLog($ebay_profile->id, 'add_customer', $res);
            $id_customer = $customer->id;
        }
        $this->id_customers[$ebay_profile->id_shop] = $id_customer;
        return $id_customer;
    }
开发者ID:anantha89,项目名称:gpprestashop,代码行数:31,代码来源:EbayOrder.php

示例13: processSubmitLogin

 public function processSubmitLogin($provider)
 {
     $social_customer = $this->socialNetworkList[$provider]->processSubmitLogin();
     if (!$social_customer || !$social_customer->id_user) {
         FSLTools::returnError(Tools::displayError('Invalid social account'));
     }
     $customer = null;
     if ($social_customer->id_customer) {
         // If social customer already exist, just login
         $customer = new Customer($social_customer->id_customer);
     } else {
         if (Tools::getValue('createAccount') == 'on' || Tools::getValue('createAccount') == 'true' || Tools::getValue('createAccount') == '1') {
             if (Customer::customerExists($social_customer->email)) {
                 // Social customer not exist, but customer prestashop already exist. Update it.
                 $customer = new Customer();
                 $authentication = $customer->getByEmail($social_customer->email);
                 if (isset($authentication->active) && !$authentication->active) {
                     FSLTools::returnError(Tools::displayError('Your account isn\'t available at this time, please contact us'));
                 } else {
                     if (!$authentication || !$customer->id) {
                         FSLTools::returnError(Tools::displayError('Authentication failed.'));
                     } else {
                         if ($this->context->customer->isLogged() && $customer->id != $this->context->customer->id) {
                             FSLTools::returnError(Tools::displayError('Your current Prestashop account not corresponding to your Social account.'));
                         } else {
                             if (!$customer->birthday && $social_customer->birthday) {
                                 // Update customer if needed
                                 $customer->birthday = $social_customer->birthday;
                                 $customer->update();
                             }
                         }
                     }
                 }
             } else {
                 // Create both social and prestashop customers.
                 $customer = new Customer();
                 $customer->id_shop = $this->context->shop->id;
                 $customer->firstname = $social_customer->firstname;
                 $customer->lastname = $social_customer->lastname;
                 $customer->email = $social_customer->email;
                 $customer->id_gender = $social_customer->id_gender;
                 $customer->newsletter = (bool) Configuration::get('FSL_CUSTOMER_NWSL');
                 $customer->optin = (bool) Configuration::get('FSL_CUSTOMER_OPTIN');
                 $passwd = Tools::passwdGen();
                 $customer->passwd = Tools::encrypt($passwd);
                 if ($social_customer->birthday) {
                     $customer->birthday = $social_customer->birthday;
                 }
                 if (!$customer->add()) {
                     FSLTools::returnError(Tools::displayError('Error during account creation.'));
                 }
                 if ($customer->newsletter) {
                     FSLTools::processCustomerNewsletter($customer);
                 }
                 Hook::exec('actionCustomerAccountAdd', array('_POST' => $_POST, 'newCustomer' => $customer));
                 if (!FSLTools::sendConfirmationMail($social_customer, $passwd)) {
                     FSLTools::returnError(Tools::displayError('The email cannot be sent.'));
                 }
             }
             if ($customer != null && $customer->id) {
                 $social_customer->id_customer = $customer->id;
                 $social_customer->id_shop = $customer->id_shop;
                 $social_customer->add();
                 // Add social customer
             }
         } else {
             FSLTools::returnAjax();
         }
     }
     if (!$this->context->customer->isLogged() && $customer != null) {
         $this->processLogin($customer);
     }
     if (($back = Tools::getValue('back')) && $back == Tools::secureReferrer($back)) {
         $redirect_url = html_entity_decode($back);
     }
     // redirection: if cart is not empty : redirection to the cart
     if (isset(Context::getContext()->cart) && count(Context::getContext()->cart->getProducts(true)) > 0) {
         $redirect_url = Context::getContext()->link->getPageLink('order' . ($multi = (int) Tools::getValue('multi-shipping') ? '&multi-shipping=' . $multi : ''));
     } else {
         $redirect_url = Context::getContext()->link->getPageLink('my-account');
     }
     FSLTools::returnAjax($redirect_url, $social_customer);
 }
开发者ID:Benichou34,项目名称:freesociallogin,代码行数:83,代码来源:freesociallogin.php

示例14: hookbackOfficeTop

 public function hookbackOfficeTop($params)
 {
     // Check if the module is configured
     if (!Configuration::get('EBAY_PAYPAL_EMAIL')) {
         return false;
     }
     // If no update yet
     if (!Configuration::get('EBAY_ORDER_LAST_UPDATE')) {
         Configuration::updateValue('EBAY_ORDER_LAST_UPDATE', date('Y-m-d') . 'T' . date('H:i:s') . '.000Z');
     }
     // init Var
     $dateNew = date('Y-m-d') . 'T' . date('H:i:s') . '.000Z';
     if (Configuration::get('EBAY_ORDER_LAST_UPDATE') < date('Y-m-d', strtotime('-45 minutes')) . 'T' . date('H:i:s', strtotime('-45 minutes')) . '.000Z') {
         $ebay = new eBayRequest();
         $orderList = $ebay->getOrders(Configuration::get('EBAY_ORDER_LAST_UPDATE'), $dateNew);
         if ($orderList) {
             foreach ($orderList as $order) {
                 if ($order['status'] == 'Complete') {
                     $result = Db::getInstance()->getRow('SELECT `id_customer` FROM `' . _DB_PREFIX_ . 'customer` WHERE `active` = 1 AND `email` = \'' . pSQL($order['email']) . '\' AND `deleted` = 0' . (substr(_PS_VERSION_, 0, 3) == '1.3' ? '' : ' AND `is_guest` = 0'));
                     $id_customer = isset($result['id_customer']) ? $result['id_customer'] : 0;
                     // Add customer if he doesn't exist
                     if ($id_customer < 1) {
                         $customer = new Customer();
                         $customer->id_gender = 9;
                         $customer->id_default_group = 1;
                         $customer->secure_key = md5(uniqid(rand(), true));
                         $customer->email = $order['email'];
                         $customer->passwd = md5(pSQL(_COOKIE_KEY_ . rand()));
                         $customer->last_passwd_gen = pSQL(date('Y-m-d H:i:s'));
                         $customer->newsletter = 0;
                         $customer->lastname = pSQL($order['familyname']);
                         $customer->firstname = pSQL($order['firstname']);
                         $customer->active = 1;
                         $customer->add();
                         $id_customer = $customer->id;
                     }
                     $address = new Address();
                     $address->id_customer = (int) $id_customer;
                     $address->id_country = (int) Country::getByIso($order['country_iso_code']);
                     $address->alias = 'eBay ' . date('Y-m-d H:i:s');
                     $address->lastname = pSQL($order['familyname']);
                     $address->firstname = pSQL($order['firstname']);
                     $address->address1 = pSQL($order['address1']);
                     $address->address2 = pSQL($order['address2']);
                     $address->postcode = pSQL($order['postalcode']);
                     $address->city = pSQL($order['city']);
                     $address->phone = pSQL($order['phone']);
                     $address->active = 1;
                     $address->add();
                     $id_address = $address->id;
                     $flag = 1;
                     foreach ($order['product_list'] as $product) {
                         if ((int) $product['id_product'] < 1 || !Db::getInstance()->getValue('SELECT `id_product` FROM `' . _DB_PREFIX_ . 'product` WHERE `id_product` = ' . (int) $product['id_product'])) {
                             $flag = 0;
                         }
                         if (isset($product['id_product_attribute']) && !Db::getInstance()->getValue('SELECT `id_product_attribute` FROM `' . _DB_PREFIX_ . 'product_attribute` WHERE `id_product` = ' . (int) $product['id_product'] . ' AND `id_product_attribute` = ' . (int) $product['id_product_attribute'])) {
                             $flag = 0;
                         }
                     }
                     if ($flag == 1) {
                         $cartAdd = new Cart();
                         $cartAdd->id_customer = $id_customer;
                         $cartAdd->id_address_invoice = $id_address;
                         $cartAdd->id_address_delivery = $id_address;
                         $cartAdd->id_carrier = 1;
                         $cartAdd->id_lang = $this->id_lang;
                         $cartAdd->id_currency = Currency::getIdByIsoCode('EUR');
                         $cartAdd->add();
                         foreach ($order['product_list'] as $product) {
                             $cartAdd->updateQty((int) $product['quantity'], (int) $product['id_product'], isset($product['id_product_attribute']) ? $product['id_product_attribute'] : NULL);
                         }
                         $cartAdd->update();
                         // Fix on sending e-mail
                         Db::getInstance()->autoExecute(_DB_PREFIX_ . 'customer', array('email' => 'NOSEND-EBAY'), 'UPDATE', '`id_customer` = ' . (int) $id_customer);
                         $customerClear = new Customer();
                         if (method_exists($customerClear, 'clearCache')) {
                             $customerClear->clearCache(true);
                         }
                         // Validate order
                         $paiement = new eBayPayment();
                         $paiement->validateOrder(intval($cartAdd->id), _PS_OS_PAYMENT_, floatval($cartAdd->getOrderTotal(true, 3)), 'Paypal eBay', NULL, array(), intval($cartAdd->id_currency));
                         $id_order = $paiement->currentOrder;
                         // Fix on sending e-mail
                         Db::getInstance()->autoExecute(_DB_PREFIX_ . 'customer', array('email' => pSQL($order['email'])), 'UPDATE', '`id_customer` = ' . (int) $id_customer);
                         // Update price (because of possibility of price impact)
                         $updateOrder = array('total_paid' => floatval($order['amount']), 'total_paid_real' => floatval($order['amount']), 'total_products' => floatval($order['amount']), 'total_products_wt' => floatval($order['amount']), 'total_shipping' => floatval($order['shippingServiceCost']));
                         Db::getInstance()->autoExecute(_DB_PREFIX_ . 'orders', $updateOrder, 'UPDATE', '`id_order` = ' . (int) $id_order);
                         foreach ($order['product_list'] as $product) {
                             Db::getInstance()->autoExecute(_DB_PREFIX_ . 'order_detail', array('product_price' => floatval($product['price']), 'tax_rate' => 0, 'reduction_percent' => 0), 'UPDATE', '`id_order` = ' . (int) $id_order . ' AND `product_id` = ' . (int) $product['id_product'] . ' AND `product_attribute_id` = ' . (int) $product['id_product_attribute']);
                         }
                     }
                 }
             }
         }
         Configuration::updateValue('EBAY_ORDER_LAST_UPDATE', $dateNew);
     }
 }
开发者ID:priyankajsr19,项目名称:indusdiva2,代码行数:97,代码来源:ebay.php

示例15: createCustomerGuestAccount

 public function createCustomerGuestAccount($encoder, $buyerDictionary, $addressDictionary = array())
 {
     global $cookie;
     // taken from AuthController
     // no need to create if already logged in and has a customer id
     if ($cookie->logged && $cookie->id_customer) {
         return;
     }
     // make sure we can create a guest account
     if (!Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) {
         CartAPI_Helpers::dieOnError($encoder, 'RegisterNotAuthorized', CartAPI_Handlers_Helpers::removeHtmlTags(Tools::displayError('You cannot create a guest account.')));
     }
     // prepare the fields inside the POST (so we can use Prestashop's validateController)
     unset($_POST['email']);
     if (isset($buyerDictionary['Email'])) {
         $_POST['email'] = $buyerDictionary['Email'];
     }
     unset($_POST['passwd']);
     $_POST['passwd'] = md5(time() . _COOKIE_KEY_);
     unset($_POST['firstname']);
     if (isset($addressDictionary['FirstName'])) {
         $_POST['firstname'] = $addressDictionary['FirstName'];
     }
     // take from address as backup
     if (isset($buyerDictionary['FirstName'])) {
         $_POST['firstname'] = $buyerDictionary['FirstName'];
     }
     // take from buyer if given
     unset($_POST['lastname']);
     if (isset($addressDictionary['LastName'])) {
         $_POST['lastname'] = $addressDictionary['LastName'];
     }
     // take from address as backup
     if (isset($buyerDictionary['LastName'])) {
         $_POST['lastname'] = $buyerDictionary['LastName'];
     }
     // take from buyer if given
     // verify fields are valid
     $customer = new Customer();
     if (_PS_VERSION_ < '1.5') {
         $errors = $customer->validateControler();
     } else {
         $errors = $customer->validateController();
     }
     if (is_array($errors) && count($errors) > 0) {
         CartAPI_Helpers::dieOnError($encoder, 'RegisterNotAuthorized', CartAPI_Handlers_Helpers::removeHtmlTags($errors[0]));
     }
     // add the new user
     $customer->active = 1;
     $customer->is_guest = 1;
     if (!$customer->add()) {
         CartAPI_Helpers::dieOnError($encoder, 'RegisterNotAuthorized', CartAPI_Handlers_Helpers::removeHtmlTags(Tools::displayError('An error occurred while creating your account.')));
     }
     // sync the cookie
     $loginHandler = CartAPI_Handlers_Helpers::newHandlerInstance($encoder, 'Login');
     $loginHandler->syncCookie($customer);
 }
开发者ID:madeny,项目名称:cartapi-plugin-prestashop,代码行数:57,代码来源:Order.php


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