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


PHP Customer::customerIdExistsStatic方法代码示例

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


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

示例1: init

 public function init()
 {
     self::$amz_payments = new AmzPayments();
     $this->isLogged = (bool) $this->context->customer->id && Customer::customerIdExistsStatic((int) $this->context->cookie->id_customer);
     parent::init();
     /* Disable some cache related bugs on the cart/order */
     header('Cache-Control: no-cache, must-revalidate');
     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
     $this->display_column_left = false;
     $this->display_column_right = false;
     $this->service = self::$amz_payments->getService();
 }
开发者ID:paeddl,项目名称:amzpayments-1,代码行数:12,代码来源:connect_accounts.php

示例2: init

 /**
  * Initialize parent order controller
  * @see FrontController::init()
  */
 public function init()
 {
     $this->isLogged = (bool) ($this->context->customer->id && Customer::customerIdExistsStatic((int) $this->context->cookie->id_customer));
     parent::init();
     /* Disable some cache related bugs on the cart/order */
     header('Cache-Control: no-cache, must-revalidate');
     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
     $this->nbProducts = $this->context->cart->nbProducts();
     if (!$this->context->customer->isLogged(true) && $this->context->getMobileDevice() && Tools::getValue('step')) {
         Tools::redirect($this->context->link->getPageLink('authentication', true, (int) $this->context->language->id, $params));
     }
     // Redirect to the good order process
     if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 0 && Dispatcher::getInstance()->getController() != 'order') {
         Tools::redirect('index.php?controller=order');
     }
     if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1 && Dispatcher::getInstance()->getController() != 'orderopc') {
         if (isset($_GET['step']) && $_GET['step'] == 3) {
             Tools::redirect('index.php?controller=order-opc&isPaymentStep=true');
         }
         Tools::redirect('index.php?controller=order-opc');
     }
     if (Configuration::get('PS_CATALOG_MODE')) {
         $this->errors[] = Tools::displayError('This store has not accepted your new order.');
     }
     if (Tools::isSubmit('submitReorder') && ($id_order = (int) Tools::getValue('id_order'))) {
         $oldCart = new Cart(Order::getCartIdStatic($id_order, $this->context->customer->id));
         $duplication = $oldCart->duplicate();
         if (!$duplication || !Validate::isLoadedObject($duplication['cart'])) {
             $this->errors[] = Tools::displayError('Sorry. We cannot renew your order.');
         } else {
             if (!$duplication['success']) {
                 $this->errors[] = Tools::displayError('Some items are no longer available, and we are unable to renew your order.');
             } else {
                 $this->context->cookie->id_cart = $duplication['cart']->id;
                 $this->context->cookie->write();
                 if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) {
                     Tools::redirect('index.php?controller=order-opc');
                 }
                 Tools::redirect('index.php?controller=order');
             }
         }
     }
     if ($this->nbProducts) {
         if (CartRule::isFeatureActive()) {
             if (Tools::isSubmit('submitAddDiscount')) {
                 if (!($code = trim(Tools::getValue('discount_name')))) {
                     $this->errors[] = Tools::displayError('You must enter a voucher code.');
                 } elseif (!Validate::isCleanHtml($code)) {
                     $this->errors[] = Tools::displayError('The voucher code is invalid.');
                 } else {
                     if (($cartRule = new CartRule(CartRule::getIdByCode($code))) && Validate::isLoadedObject($cartRule)) {
                         if ($error = $cartRule->checkValidity($this->context, false, true)) {
                             $this->errors[] = $error;
                         } else {
                             $this->context->cart->addCartRule($cartRule->id);
                             if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) {
                                 Tools::redirect('index.php?controller=order-opc&addingCartRule=1');
                             }
                             Tools::redirect('index.php?controller=order&addingCartRule=1');
                         }
                     } else {
                         $this->errors[] = Tools::displayError('This voucher does not exists.');
                     }
                 }
                 $this->context->smarty->assign(array('errors' => $this->errors, 'discount_name' => Tools::safeOutput($code)));
             } elseif (($id_cart_rule = (int) Tools::getValue('deleteDiscount')) && Validate::isUnsignedId($id_cart_rule)) {
                 $this->context->cart->removeCartRule($id_cart_rule);
                 Tools::redirect('index.php?controller=order-opc');
             }
         }
         /* Is there only virtual product in cart */
         if ($isVirtualCart = $this->context->cart->isVirtualCart()) {
             $this->setNoCarrier();
         }
     }
     $this->context->smarty->assign('back', Tools::safeOutput(Tools::getValue('back')));
 }
开发者ID:toufikadfab,项目名称:PrestaShop-1.5,代码行数:81,代码来源:ParentOrderController.php

示例3: addressImportOne

 protected function addressImportOne($info, $force_ids, $validateOnly = false)
 {
     AdminImportController::setDefaultValues($info);
     if ($force_ids && isset($info['id']) && (int) $info['id']) {
         $address = new Address((int) $info['id']);
     } else {
         if (array_key_exists('id', $info) && (int) $info['id'] && Address::addressExists((int) $info['id'])) {
             $address = new Address((int) $info['id']);
         } else {
             $address = new Address();
         }
     }
     AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $address);
     if (isset($address->country) && is_numeric($address->country)) {
         if (Country::getNameById(Configuration::get('PS_LANG_DEFAULT'), (int) $address->country)) {
             $address->id_country = (int) $address->country;
         }
     } elseif (isset($address->country) && is_string($address->country) && !empty($address->country)) {
         if ($id_country = Country::getIdByName(null, $address->country)) {
             $address->id_country = (int) $id_country;
         } else {
             $country = new Country();
             $country->active = 1;
             $country->name = AdminImportController::createMultiLangField($address->country);
             $country->id_zone = 0;
             // Default zone for country to create
             $country->iso_code = Tools::strtoupper(Tools::substr($address->country, 0, 2));
             // Default iso for country to create
             $country->contains_states = 0;
             // Default value for country to create
             $lang_field_error = $country->validateFieldsLang(UNFRIENDLY_ERROR, true);
             if (($field_error = $country->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $country->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && !$validateOnly && $country->add()) {
                 $address->id_country = (int) $country->id;
             } else {
                 if (!$validateOnly) {
                     $default_language_id = (int) Configuration::get('PS_LANG_DEFAULT');
                     $this->errors[] = sprintf($this->trans('%s cannot be saved', array(), 'Admin.Parameters.Notification'), $country->name[$default_language_id]);
                 }
                 if ($field_error !== true || isset($lang_field_error) && $lang_field_error !== true) {
                     $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
                 }
             }
         }
     }
     if (isset($address->state) && is_numeric($address->state)) {
         if (State::getNameById((int) $address->state)) {
             $address->id_state = (int) $address->state;
         }
     } elseif (isset($address->state) && is_string($address->state) && !empty($address->state)) {
         if ($id_state = State::getIdByName($address->state)) {
             $address->id_state = (int) $id_state;
         } else {
             $state = new State();
             $state->active = 1;
             $state->name = $address->state;
             $state->id_country = isset($country->id) ? (int) $country->id : 0;
             $state->id_zone = 0;
             // Default zone for state to create
             $state->iso_code = Tools::strtoupper(Tools::substr($address->state, 0, 2));
             // Default iso for state to create
             $state->tax_behavior = 0;
             if (($field_error = $state->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $state->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && !$validateOnly && $state->add()) {
                 $address->id_state = (int) $state->id;
             } else {
                 if (!$validateOnly) {
                     $this->errors[] = sprintf($this->trans('%s cannot be saved', array(), 'Admin.Parameters.Notification'), $state->name);
                 }
                 if ($field_error !== true || isset($lang_field_error) && $lang_field_error !== true) {
                     $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
                 }
             }
         }
     }
     if (isset($address->customer_email) && !empty($address->customer_email)) {
         if (Validate::isEmail($address->customer_email)) {
             // a customer could exists in different shop
             $customer_list = Customer::getCustomersByEmail($address->customer_email);
             if (count($customer_list) == 0) {
                 $this->errors[] = sprintf(Tools::displayError('%1$s does not exist in database %2$s (ID: %3$s), and therefore cannot be ' . ($validateOnly ? 'validated' : 'saved')), Db::getInstance()->getMsgError(), $address->customer_email, isset($info['id']) && !empty($info['id']) ? $info['id'] : 'null');
             }
         } else {
             $this->errors[] = sprintf($this->trans('"%s" is not a valid email address.', array(), 'Admin.Parameters.Notification'), $address->customer_email);
             return;
         }
     } elseif (isset($address->id_customer) && !empty($address->id_customer)) {
         if (Customer::customerIdExistsStatic((int) $address->id_customer)) {
             $customer = new Customer((int) $address->id_customer);
             // a customer could exists in different shop
             $customer_list = Customer::getCustomersByEmail($customer->email);
             if (count($customer_list) == 0) {
                 $this->errors[] = sprintf(Tools::displayError('%1$s does not exist in database %2$s (ID: %3$s), and therefore cannot be ' . ($validateOnly ? 'validated' : 'saved')), Db::getInstance()->getMsgError(), $customer->email, (int) $address->id_customer);
             }
         } else {
             $this->errors[] = sprintf(Tools::displayError('The customer ID #%d does not exist in the database, and therefore cannot be ' . ($validateOnly ? 'validated' : 'saved')), $address->id_customer);
         }
     } else {
         $customer_list = array();
         $address->id_customer = 0;
     }
     if (isset($address->manufacturer) && is_numeric($address->manufacturer) && Manufacturer::manufacturerExists((int) $address->manufacturer)) {
//.........这里部分代码省略.........
开发者ID:M03G,项目名称:PrestaShop,代码行数:101,代码来源:AdminImportController.php

示例4: customerIdExists

 public function customerIdExists($id_customer)
 {
     return Customer::customerIdExistsStatic((int) $id_customer);
 }
开发者ID:dev-lav,项目名称:htdocs,代码行数:4,代码来源:Customer.php

示例5: _getPaymentMethods

 protected function _getPaymentMethods()
 {
     if (!$this->isLogged) {
         return '<p class="warning">' . Tools::displayError('Please sign in to see payment methods') . '</p>';
     }
     if (self::$cart->OrderExists()) {
         return '<p class="warning">' . Tools::displayError('Error: this order is already validated') . '</p>';
     }
     if (!self::$cart->id_customer or !Customer::customerIdExistsStatic(self::$cart->id_customer) or Customer::isBanned(self::$cart->id_customer)) {
         return '<p class="warning">' . Tools::displayError('Error: no customer') . '</p>';
     }
     $address_delivery = new Address(self::$cart->id_address_delivery);
     $address_invoice = self::$cart->id_address_delivery == self::$cart->id_address_invoice ? $address_delivery : new Address(self::$cart->id_address_invoice);
     if (!self::$cart->id_address_delivery or !self::$cart->id_address_invoice or !Validate::isLoadedObject($address_delivery) or !Validate::isLoadedObject($address_invoice) or $address_invoice->deleted or $address_delivery->deleted) {
         return '<p class="warning">' . Tools::displayError('Error: please choose an address') . '</p>';
     }
     if (!self::$cart->id_carrier and !self::$cart->isVirtualCart()) {
         return '<p class="warning">' . Tools::displayError('Error: please choose a carrier') . '</p>';
     } elseif (self::$cart->id_carrier != 0) {
         $carrier = new Carrier((int) self::$cart->id_carrier);
         if (!Validate::isLoadedObject($carrier) or $carrier->deleted or !$carrier->active) {
             return '<p class="warning">' . Tools::displayError('Error: the carrier is invalid') . '</p>';
         }
     }
     if (!self::$cart->id_currency) {
         return '<p class="warning">' . Tools::displayError('Error: no currency has been selected') . '</p>';
     }
     if (!self::$cookie->checkedTOS and Configuration::get('PS_CONDITIONS')) {
         return '<p class="warning">' . Tools::displayError('Please accept Terms of Service') . '</p>';
     }
     /* If some products have disappear */
     if (!self::$cart->checkQuantities()) {
         return '<p class="warning">' . Tools::displayError('An item in your cart is no longer available, you cannot proceed with your order.') . '</p>';
     }
     /* Check minimal amount */
     $currency = Currency::getCurrency((int) self::$cart->id_currency);
     $minimalPurchase = Tools::convertPrice((double) Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
     if (self::$cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimalPurchase) {
         return '<p class="warning">' . Tools::displayError('A minimum purchase total of') . ' ' . Tools::displayPrice($minimalPurchase, $currency) . ' ' . Tools::displayError('is required in order to validate your order.') . '</p>';
     }
     /* Bypass payment step if total is 0 */
     if (self::$cart->getOrderTotal() <= 0) {
         return '<p class="center"><input type="button" class="exclusive_large" name="confirmOrder" id="confirmOrder" value="' . Tools::displayError('I confirm my order') . '" onclick="confirmFreeOrder();" /></p>';
     }
     $return = Module::hookExecPayment();
     if (!$return) {
         return '<p class="warning">' . Tools::displayError('No payment method is available') . '</p>';
     }
     return $return;
 }
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:50,代码来源:OrderOpcController.php

示例6: _getPaymentMethods

 protected function _getPaymentMethods()
 {
     if (!$this->isLogged) {
         return '<p class="warning">' . Tools::displayError('Please sign in to see payment methods.') . '</p>';
     }
     if ($this->context->cart->OrderExists()) {
         return '<p class="warning">' . Tools::displayError('Error: This order has already been validated.') . '</p>';
     }
     if (!$this->context->cart->id_customer || !Customer::customerIdExistsStatic($this->context->cart->id_customer) || Customer::isBanned($this->context->cart->id_customer)) {
         return '<p class="warning">' . Tools::displayError('Error: No customer.') . '</p>';
     }
     $address_delivery = new Address($this->context->cart->id_address_delivery);
     $address_invoice = $this->context->cart->id_address_delivery == $this->context->cart->id_address_invoice ? $address_delivery : new Address($this->context->cart->id_address_invoice);
     if (!$this->context->cart->id_address_delivery || !$this->context->cart->id_address_invoice || !Validate::isLoadedObject($address_delivery) || !Validate::isLoadedObject($address_invoice) || $address_invoice->deleted || $address_delivery->deleted) {
         return '<p class="warning">' . Tools::displayError('Error: Please select an address.') . '</p>';
     }
     if (count($this->context->cart->getDeliveryOptionList()) == 0 && !$this->context->cart->isVirtualCart()) {
         if ($this->context->cart->isMultiAddressDelivery()) {
             return '<p class="warning">' . Tools::displayError('Error: None of your chosen carriers deliver to some of  the addresses you\'ve selected.') . '</p>';
         } else {
             return '<p class="warning">' . Tools::displayError('Error: None of your chosen carriers deliver to the address you\'ve selected.') . '</p>';
         }
     }
     if (!$this->context->cart->getDeliveryOption(null, false) && !$this->context->cart->isVirtualCart()) {
         return '<p class="warning">' . Tools::displayError('Error: Please choose a carrier.') . '</p>';
     }
     if (!$this->context->cart->id_currency) {
         return '<p class="warning">' . Tools::displayError('Error: No currency has been selected.') . '</p>';
     }
     if (!$this->context->cookie->checkedTOS && Configuration::get('PS_CONDITIONS')) {
         return '<p class="warning">' . Tools::displayError('Please accept the Terms of Service.') . '</p>';
     }
     /* If some products have disappear */
     if (!$this->context->cart->checkQuantities()) {
         return '<p class="warning">' . Tools::displayError('An item in your cart is no longer available. You cannot proceed with your order.') . '</p>';
     }
     /* Check minimal amount */
     $currency = Currency::getCurrency((int) $this->context->cart->id_currency);
     $minimal_purchase = Tools::convertPrice((double) Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
     if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase) {
         return '<p class="warning">' . sprintf(Tools::displayError('A minimum purchase total of %1s (tax excl.) is required in order to validate your order, current purchase total is %2s (tax excl.).'), Tools::displayPrice($minimal_purchase, $currency), Tools::displayPrice($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS), $currency)) . '</p>';
     }
     /* Bypass payment step if total is 0 */
     if ($this->context->cart->getOrderTotal() <= 0) {
         return '<p class="center"><button class="button btn btn-default button-medium" name="confirmOrder" id="confirmOrder" onclick="confirmFreeOrder();" type="submit"> <span>' . Tools::displayError('I confirm my order.') . '</span></button></p>';
     }
     $return = Hook::exec('displayPayment');
     if (!$return) {
         return '<p class="warning">' . Tools::displayError('No payment method is available for use at this time. ') . '</p>';
     }
     return $return;
 }
开发者ID:dev-lav,项目名称:htdocs,代码行数:52,代码来源:OrderOpcController.php

示例7: addressImport

 public function addressImport()
 {
     $this->receiveTab();
     $default_language_id = (int) Configuration::get('PS_LANG_DEFAULT');
     $handle = $this->openCsvFile();
     AdminImportController::setLocale();
     for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) {
         if (Tools::getValue('convert')) {
             $line = $this->utf8EncodeArray($line);
         }
         $info = AdminImportController::getMaskedRow($line);
         AdminImportController::setDefaultValues($info);
         $address = new Address();
         AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $address);
         if (isset($address->country) && is_numeric($address->country)) {
             if (Country::getNameById(Configuration::get('PS_LANG_DEFAULT'), (int) $address->country)) {
                 $address->id_country = (int) $address->country;
             }
         } elseif (isset($address->country) && is_string($address->country) && !empty($address->country)) {
             if ($id_country = Country::getIdByName(null, $address->country)) {
                 $address->id_country = (int) $id_country;
             } else {
                 $country = new Country();
                 $country->active = 1;
                 $country->name = AdminImportController::createMultiLangField($address->country);
                 $country->id_zone = 0;
                 // Default zone for country to create
                 $country->iso_code = Tools::strtoupper(Tools::substr($address->country, 0, 2));
                 // Default iso for country to create
                 $country->contains_states = 0;
                 // Default value for country to create
                 $lang_field_error = $country->validateFieldsLang(UNFRIENDLY_ERROR, true);
                 if (($field_error = $country->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $country->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $country->add()) {
                     $address->id_country = (int) $country->id;
                 } else {
                     $this->errors[] = sprintf(Tools::displayError('%s cannot be saved'), $country->name[$default_language_id]);
                     $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
                 }
             }
         }
         if (isset($address->state) && is_numeric($address->state)) {
             if (State::getNameById((int) $address->state)) {
                 $address->id_state = (int) $address->state;
             }
         } elseif (isset($address->state) && is_string($address->state) && !empty($address->state)) {
             if ($id_state = State::getIdByName($address->state)) {
                 $address->id_state = (int) $id_state;
             } else {
                 $state = new State();
                 $state->active = 1;
                 $state->name = $address->state;
                 $state->id_country = isset($country->id) ? (int) $country->id : 0;
                 $state->id_zone = 0;
                 // Default zone for state to create
                 $state->iso_code = Tools::strtoupper(Tools::substr($address->state, 0, 2));
                 // Default iso for state to create
                 $state->tax_behavior = 0;
                 if (($field_error = $state->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $state->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $state->add()) {
                     $address->id_state = (int) $state->id;
                 } else {
                     $this->errors[] = sprintf(Tools::displayError('%s cannot be saved'), $state->name);
                     $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
                 }
             }
         }
         if (isset($address->customer_email) && !empty($address->customer_email)) {
             if (Validate::isEmail($address->customer_email)) {
                 // a customer could exists in different shop
                 $customer_list = Customer::getCustomersByEmail($address->customer_email);
                 if (count($customer_list) == 0) {
                     $this->errors[] = sprintf(Tools::displayError('%1$s does not exist in database %2$s (ID: %3$s), and therefore cannot be saved.'), Db::getInstance()->getMsgError(), $address->customer_email, isset($info['id']) && !empty($info['id']) ? $info['id'] : 'null');
                 }
             } else {
                 $this->errors[] = sprintf(Tools::displayError('"%s" is not a valid email address.'), $address->customer_email);
                 continue;
             }
         } elseif (isset($address->id_customer) && !empty($address->id_customer)) {
             if (Customer::customerIdExistsStatic((int) $address->id_customer)) {
                 $customer = new Customer((int) $address->id_customer);
                 // a customer could exists in different shop
                 $customer_list = Customer::getCustomersByEmail($customer->email);
                 if (count($customer_list) == 0) {
                     $this->errors[] = sprintf(Tools::displayError('%1$s does not exist in database %2$s (ID: %3$s), and therefore cannot be saved.'), Db::getInstance()->getMsgError(), $customer->email, (int) $address->id_customer);
                 }
             } else {
                 $this->errors[] = sprintf(Tools::displayError('The customer ID #%d does not exist in the database, and therefore cannot be saved.'), $address->id_customer);
             }
         } else {
             $customer_list = array();
             $address->id_customer = 0;
         }
         if (isset($address->manufacturer) && is_numeric($address->manufacturer) && Manufacturer::manufacturerExists((int) $address->manufacturer)) {
             $address->id_manufacturer = (int) $address->manufacturer;
         } elseif (isset($address->manufacturer) && is_string($address->manufacturer) && !empty($address->manufacturer)) {
             $manufacturer = new Manufacturer();
             $manufacturer->name = $address->manufacturer;
             if (($field_error = $manufacturer->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $manufacturer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $manufacturer->add()) {
                 $address->id_manufacturer = (int) $manufacturer->id;
             } else {
                 $this->errors[] = Db::getInstance()->getMsgError() . ' ' . sprintf(Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $manufacturer->name, isset($manufacturer->id) && !empty($manufacturer->id) ? $manufacturer->id : 'null');
//.........这里部分代码省略.........
开发者ID:ecssjapan,项目名称:guiding-you-afteropen,代码行数:101,代码来源:AdminImportController.php

示例8: init

 public function init()
 {
     if (!$this->isOpcModuleActive()) {
         return parent::init();
     }
     if (Tools::getIsset('id_carrier') && strpos(Tools::getValue('id_carrier'), ",") > 0) {
         $_POST['id_carrier'] = Cart::intifier(Tools::getValue('id_carrier'));
     }
     $this->opc_templates_path = _PS_MODULE_DIR_ . 'onepagecheckout/views/templates/front';
     $this->origInit();
     $this->_assignOpcSettings();
     if ($this->opc_config != null && $this->opc_config['goods_return_cms'] > 0) {
         $cms = new CMS((int) $this->opc_config['goods_return_cms'], (int) $this->context->language->id);
         $link_goods_return = $this->context->link->getCMSLink($cms, $cms->link_rewrite, true);
         if (!strpos($link_goods_return, '?')) {
             $link_goods_return .= '?content_only=1';
         } else {
             $link_goods_return .= '&content_only=1';
         }
         $this->context->smarty->assign("link_goods_return", $link_goods_return);
     }
     $this->_setInfoBlockContent();
     $this->_setExtraDivPaymentBlock();
     if ($this->nbProducts) {
         $this->context->smarty->assign('virtual_cart', false);
     }
     $this->context->smarty->assign('is_multi_address_delivery', $this->context->cart->isMultiAddressDelivery() || (int) Tools::getValue('multi-shipping') == 1);
     $this->context->smarty->assign('open_multishipping_fancybox', (int) Tools::getValue('multi-shipping') == 1);
     $this->context->smarty->assign('order_process_type', Configuration::get('PS_ORDER_PROCESS_TYPE'));
     $this->context->smarty->assign('one_phone_at_least', (int) Configuration::get('PS_ONE_PHONE_AT_LEAST'));
     $this->inv_first_on = isset($this->opc_config) && isset($this->opc_config["invoice_first"]) && $this->opc_config["invoice_first"] == "1";
     $this->default_ps_carriers = isset($this->opc_config) && isset($this->opc_config["default_ps_carriers"]) && $this->opc_config["default_ps_carriers"] == "1";
     if (version_compare(_PS_VERSION_, "1.5.2.0") <= 0) {
         $this->isLogged = (bool) ($this->context->customer->id && Customer::customerIdExistsStatic((int) $this->context->cookie->id_customer));
     }
     if ($this->context->cart->nbProducts()) {
         if (Tools::isSubmit('ajax')) {
             if (Tools::isSubmit('method')) {
                 switch (Tools::getValue('method')) {
                     case 'updateMessage':
                         if (Tools::isSubmit('message')) {
                             $txtMessage = urldecode(Tools::getValue('message'));
                             $this->_updateMessage($txtMessage);
                             if (count($this->errors)) {
                                 die('{"hasError" : true, "errors" : ["' . implode('\',\'', $this->errors) . '"]}');
                             }
                             die(true);
                         }
                         break;
                     case 'updateCarrierAndGetPayments':
                         if ((Tools::isSubmit('delivery_option') || Tools::isSubmit('id_carrier')) && Tools::isSubmit('recyclable') && Tools::isSubmit('gift') && Tools::isSubmit('gift_message')) {
                             $this->_assignWrappingAndTOS();
                             CartRule::autoRemoveFromCart($this->context);
                             CartRule::autoAddToCart($this->context);
                             if ($this->_processCarrier()) {
                                 $carriers = $this->context->cart->simulateCarriersOutput();
                                 $return = array_merge(array('HOOK_TOP_PAYMENT' => Hook::exec('displayPaymentTop'), 'HOOK_PAYMENT' => $this->_getPaymentMethods(), 'carrier_data' => $this->_getCarrierList(), 'HOOK_BEFORECARRIER' => Hook::exec('displayBeforeCarrier', array('carriers' => $carriers))), $this->getFormatedSummaryDetail());
                                 Cart::addExtraCarriers($return);
                                 die(Tools::jsonEncode($return));
                             } else {
                                 $this->errors[] = Tools::displayError('Error occurred while updating cart.');
                             }
                             if (count($this->errors)) {
                                 die('{"hasError" : true, "errors" : ["' . implode('\',\'', $this->errors) . '"]}');
                             }
                             exit;
                         }
                         break;
                     case 'updateTOSStatusAndGetPayments':
                         if (Tools::isSubmit('checked')) {
                             $this->context->cookie->checkedTOS = (int) Tools::getValue('checked');
                             die(Tools::jsonEncode(array()));
                         }
                         break;
                     case 'updatePaymentsOnly':
                         die(Tools::jsonEncode(array('HOOK_TOP_PAYMENT' => Hook::exec('displayPaymentTop'), 'HOOK_PAYMENT' => self::_getPaymentMethods())));
                         break;
                     case 'getCarrierList':
                         $this->context->smarty->assign('isVirtualCart', $this->context->cart->isVirtualCart());
                         $result = $this->_getCarrierList();
                         $result = array_merge($result, array('HOOK_TOP_PAYMENT' => Hook::exec('displayPaymentTop'), 'HOOK_PAYMENT' => $this->_getPaymentMethods()), $this->getFormatedSummaryDetail());
                         die(Tools::jsonEncode($result));
                         break;
                     case 'editCustomer':
                         if (!$this->isLogged) {
                             exit;
                         }
                         if (Tools::getValue('years')) {
                             $this->context->customer->birthday = (int) Tools::getValue('years') . '-' . (int) Tools::getValue('months') . '-' . (int) Tools::getValue('days');
                         }
                         if (trim(Tools::getValue('customer_lastname')) == "") {
                             $_POST['customer_lastname'] = $this->inv_first_on ? Tools::getValue('lastname_invoice') : Tools::getValue('lastname');
                         }
                         if (trim(Tools::getValue('customer_firstname')) == "") {
                             $_POST['customer_firstname'] = $this->inv_first_on ? Tools::getValue('firstname_invoice') : Tools::getValue('firstname');
                         }
                         $this->errors = $this->context->customer->validateController();
                         $this->context->customer->newsletter = (int) Tools::isSubmit('newsletter');
                         $this->context->customer->optin = (int) Tools::isSubmit('optin');
                         $return = array('hasError' => !empty($this->errors), 'errors' => $this->errors, 'id_customer' => (int) $this->context->customer->id, 'token' => Tools::getToken(false));
//.........这里部分代码省略.........
开发者ID:evgrishin,项目名称:se1614,代码行数:101,代码来源:OrderOpcController.php

示例9: init

 public function init()
 {
     self::$amz_payments = new AmzPayments();
     $this->isLogged = (bool) $this->context->customer->id && Customer::customerIdExistsStatic((int) $this->context->cookie->id_customer);
     parent::init();
     /* Disable some cache related bugs on the cart/order */
     header('Cache-Control: no-cache, must-revalidate');
     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
     $this->display_column_left = false;
     $this->display_column_right = false;
     // Service initialisieren
     $this->service = self::$amz_payments->getService();
     if (Tools::isSubmit('ajax')) {
         if (Tools::isSubmit('method')) {
             switch (Tools::getValue('method')) {
                 case 'redirectAuthentication':
                 case 'setusertoshop':
                     if (Tools::getValue('access_token')) {
                         $this->context->cookie->amz_access_token = AmzPayments::prepareCookieValueForPrestaShopUse(Tools::getValue('access_token'));
                         $this->context->cookie->amz_access_token_set_time = time();
                     } else {
                         if (Tools::getValue('method') == 'redirectAuthentication') {
                             Tools::redirect('index');
                         } else {
                             error_log('Error, method not submitted and no token');
                             die('error');
                         }
                     }
                     if (Tools::getValue('action') == 'fromCheckout') {
                         $accessTokenValue = AmzPayments::prepareCookieValueForAmazonPaymentsUse(Tools::getValue('access_token'));
                     } else {
                         $accessTokenValue = Tools::getValue('access_token');
                     }
                     $d = self::$amz_payments->requestTokenInfo($accessTokenValue);
                     if ($d->aud != self::$amz_payments->client_id) {
                         if (Tools::getValue('method') == 'redirectAuthentication') {
                             Tools::redirect('index');
                         } else {
                             error_log('auth error LPA');
                             die('error');
                         }
                     }
                     $d = self::$amz_payments->requestProfile($accessTokenValue);
                     $customer_userid = $d->user_id;
                     $customer_name = $d->name;
                     $customer_email = $d->email;
                     // $postcode = $d->postal_code;
                     if ($customers_local_id = AmazonPaymentsCustomerHelper::findByAmazonCustomerId($customer_userid)) {
                         // Customer already exists - login
                         Hook::exec('actionBeforeAuthentication');
                         $customer = new Customer();
                         $authentication = AmazonPaymentsCustomerHelper::getByCustomerID($customers_local_id, true, $customer);
                         if (isset($authentication->active) && !$authentication->active) {
                             $this->errors[] = Tools::displayError('Your account isn\'t available at this time, please contact us');
                         } elseif (!$authentication || !$customer->id) {
                             $this->errors[] = Tools::displayError('Authentication failed.');
                         } else {
                             $this->context->cookie->id_compare = isset($this->context->cookie->id_compare) ? $this->context->cookie->id_compare : CompareProduct::getIdCompareByIdCustomer($customer->id);
                             $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->logged = 1;
                             $customer->logged = 1;
                             $this->context->cookie->is_guest = $customer->isGuest();
                             $this->context->cookie->passwd = $customer->passwd;
                             $this->context->cookie->email = $customer->email;
                             // Add customer to the context
                             $this->context->customer = $customer;
                             if (Configuration::get('PS_CART_FOLLOWING') && (empty($this->context->cookie->id_cart) || Cart::getNbProducts($this->context->cookie->id_cart) == 0) && ($id_cart = (int) Cart::lastNoneOrderedCart($this->context->customer->id))) {
                                 $this->context->cart = new Cart($id_cart);
                             } else {
                                 $id_carrier = (int) $this->context->cart->id_carrier;
                                 $this->context->cart->id_carrier = 0;
                                 $this->context->cart->setDeliveryOption(null);
                                 $this->context->cart->id_address_delivery = (int) Address::getFirstCustomerAddressId((int) $customer->id);
                                 $this->context->cart->id_address_invoice = (int) Address::getFirstCustomerAddressId((int) $customer->id);
                             }
                             $this->context->cart->id_customer = (int) $customer->id;
                             $this->context->cart->secure_key = $customer->secure_key;
                             if ($this->ajax && isset($id_carrier) && $id_carrier && Configuration::get('PS_ORDER_PROCESS_TYPE')) {
                                 $delivery_option = array($this->context->cart->id_address_delivery => $id_carrier . ',');
                                 $this->context->cart->setDeliveryOption($delivery_option);
                             }
                             $this->context->cart->save();
                             $this->context->cookie->id_cart = (int) $this->context->cart->id;
                             $this->context->cookie->write();
                             $this->context->cart->autosetProductAddress();
                             Hook::exec('actionAuthentication');
                             // Login information have changed, so we check if the cart rules still apply
                             CartRule::autoRemoveFromCart($this->context);
                             CartRule::autoAddToCart($this->context);
                             if (Tools::getValue('action') == 'fromCheckout' && isset($this->context->cookie->amz_connect_order)) {
                                 AmzPayments::switchOrderToCustomer($this->context->customer->id, $this->context->cookie->amz_connect_order, true);
                             }
                             if (Tools::getValue('action') == 'checkout') {
                                 $goto = $this->context->link->getModuleLink('amzpayments', 'amzpayments');
                             } elseif (Tools::getValue('action') == 'fromCheckout') {
                                 $goto = 'index.php?controller=history';
                             } elseif ($this->context->cart->nbProducts()) {
                                 $goto = 'index.php?controller=order';
//.........这里部分代码省略.........
开发者ID:paeddl,项目名称:amzpayments-1,代码行数:101,代码来源:user_to_shop.php

示例10: ajax_getPaymentMethods

 public function ajax_getPaymentMethods()
 {
     $val = Context::getContext()->cookie->ulozenka;
     if (empty($val)) {
         return '<p class="warning">' . Tools::displayError('Prosím vyberte pobočku') . '</p>';
     }
     $isLogged = (bool) (Context::getContext()->customer->id && Customer::customerIdExistsStatic((int) Context::getContext()->cookie->id_customer));
     if (!$isLogged) {
         return '<p class="warning">' . Tools::displayError('Please sign in to see payment methods.') . '</p>';
     }
     if (Context::getContext()->cart->OrderExists()) {
         return '<p class="warning">' . Tools::displayError('Error: This order has already been validated.') . '</p>';
     }
     if (!Context::getContext()->cart->id_customer || !Customer::customerIdExistsStatic(Context::getContext()->cart->id_customer) || Customer::isBanned(Context::getContext()->cart->id_customer)) {
         return '<p class="warning">' . Tools::displayError('Error: No customer.') . '</p>';
     }
     $address_delivery = new Address(Context::getContext()->cart->id_address_delivery);
     $address_invoice = Context::getContext()->cart->id_address_delivery == Context::getContext()->cart->id_address_invoice ? $address_delivery : new Address(Context::getContext()->cart->id_address_invoice);
     if (!Context::getContext()->cart->id_address_delivery || !Context::getContext()->cart->id_address_invoice || !Validate::isLoadedObject($address_delivery) || !Validate::isLoadedObject($address_invoice) || $address_invoice->deleted || $address_delivery->deleted) {
         return '<p class="warning">' . Tools::displayError('Error: Please select an address.') . '</p>';
     }
     /*
      if (count(Context::getContext()->cart->getDeliveryOptionList()) == 0 && !Context::getContext()->cart->isVirtualCart())
      {
      if (Context::getContext()->cart->isMultiAddressDelivery())
      return '<p class="warning">'.Tools::displayError('Error: None of your chosen carriers deliver to some of  the addresses you\'ve selected.').'</p>';
      else
      return '<p class="warning">'.Tools::displayError('Error: None of your chosen carriers deliver to the address you\'ve selected.').'</p>';
      }
     
      if (!Context::getContext()->cart->getDeliveryOption(null, false) && !Context::getContext()->cart->isVirtualCart())
      return '<p class="warning">'.Tools::displayError('Error: Please choose a carrier.').'</p>';
     */
     if (!Context::getContext()->cart->id_currency) {
         return '<p class="warning">' . Tools::displayError('Error: No currency has been selected.') . '</p>';
     }
     if (!Context::getContext()->cookie->checkedTOS && Configuration::get('PS_CONDITIONS')) {
         return '<p class="warning">' . Tools::displayError('Please accept the Terms of Service.') . '</p>';
     }
     /* If some products have disappear */
     if (!Context::getContext()->cart->checkQuantities()) {
         return '<p class="warning">' . Tools::displayError('An item in your cart is no longer available. You cannot proceed with your order.') . '</p>';
     }
     /* Check minimal amount */
     $currency = Currency::getCurrency((int) Context::getContext()->cart->id_currency);
     $minimalPurchase = Tools::convertPrice((double) Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
     if (Context::getContext()->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimalPurchase) {
         return '<p class="warning">' . sprintf(Tools::displayError('A minimum purchase total of %s is required in order to validate your order.'), Tools::displayPrice($minimalPurchase, $currency)) . '</p>';
     }
     /* Bypass payment step if total is 0 */
     if (Context::getContext()->cart->getOrderTotal() <= 0) {
         return '<p class="center"><input type="button" class="exclusive_large" name="confirmOrder" id="confirmOrder" value="' . Tools::displayError('I confirm my order.') . '" onclick="confirmFreeOrder();" /></p>';
     }
     $return = Hook::exec('displayPayment');
     if (!$return) {
         return '<p class="warning">' . Tools::displayError('No payment method is available for use at this time. ') . '</p>';
     }
     return $return;
 }
开发者ID:ulozenka,项目名称:prestashop-1-5,代码行数:59,代码来源:ulozenka.php

示例11: customerImport

 public function customerImport()
 {
     $customer_exist = false;
     $this->receiveTab();
     $handle = $this->openCsvFile();
     AdminImportController::setLocale();
     for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) {
         if (Tools::getValue('convert')) {
             $line = $this->utf8EncodeArray($line);
         }
         $info = AdminImportController::getMaskedRow($line);
         AdminImportController::setDefaultValues($info);
         if (array_key_exists('id', $info) && (int) $info['id'] && Customer::customerIdExistsStatic((int) $info['id'])) {
             $customer = new Customer((int) $info['id']);
             $current_id_customer = $customer->id;
             $current_id_shop = $customer->id_shop;
             $current_id_shop_group = $customer->id_shop_group;
             $customer_exist = true;
             $customer_groups = $customer->getGroups();
             $addresses = $customer->getAddresses((int) Configuration::get('PS_LANG_DEFAULT'));
             foreach ($customer_groups as $key => $group) {
                 if ($group == $customer->id_default_group) {
                     unset($customer_groups[$key]);
                 }
             }
         } else {
             $customer = new Customer();
         }
         AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $customer);
         if ($customer->passwd) {
             $customer->passwd = Tools::encrypt($customer->passwd);
         }
         $id_shop_list = explode($this->multiple_value_separator, $customer->id_shop);
         $customers_shop = array();
         $customers_shop['shared'] = array();
         $default_shop = new Shop((int) Configuration::get('PS_SHOP_DEFAULT'));
         if (Shop::isFeatureActive() && $id_shop_list) {
             foreach ($id_shop_list as $id_shop) {
                 $shop = new Shop((int) $id_shop);
                 $group_shop = $shop->getGroup();
                 if ($group_shop->share_customer) {
                     if (!in_array($group_shop->id, $customers_shop['shared'])) {
                         $customers_shop['shared'][(int) $id_shop] = $group_shop->id;
                     }
                 } else {
                     $customers_shop[(int) $id_shop] = $group_shop->id;
                 }
             }
         } else {
             $default_shop = new Shop((int) Configuration::get('PS_SHOP_DEFAULT'));
             $default_shop->getGroup();
             $customers_shop[$default_shop->id] = $default_shop->getGroup()->id;
         }
         //set temporally for validate field
         $customer->id_shop = $default_shop->id;
         $customer->id_shop_group = $default_shop->getGroup()->id;
         $res = true;
         if (($field_error = $customer->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $customer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) {
             foreach ($customers_shop as $id_shop => $id_group) {
                 if ($id_shop == 'shared') {
                     foreach ($id_group as $key => $id) {
                         $customer->id_shop = (int) $key;
                         $customer->id_shop_group = (int) $id;
                         if ($customer_exist && ($current_id_shop_group == $id || in_array($current_id_shop, ShopGroup::getShopsFromGroup($id)))) {
                             $customer->id = $current_id_customer;
                             $res &= $customer->update();
                         } else {
                             unset($customer->id);
                             $res &= $customer->add();
                             if (isset($customer_groups)) {
                                 $customer->addGroups($customer_groups);
                             }
                             if (isset($addresses)) {
                                 foreach ($addresses as $address) {
                                     $address['id_customer'] = $customer->id;
                                     unset($address['country'], $address['state'], $address['state_iso'], $address['id_address']);
                                     Db::getInstance()->insert('address', $address);
                                 }
                             }
                         }
                     }
                 } else {
                     $customer->id_shop = $id_shop;
                     $customer->id_shop_group = $id_group;
                     if ($customer_exist && $id_shop == $current_id_shop) {
                         $customer->id = $current_id_customer;
                         $res &= $customer->update();
                     } else {
                         unset($customer->id);
                         $res &= $customer->add();
                         if (isset($customer_groups)) {
                             $customer->addGroups($customer_groups);
                         }
                         if (isset($addresses)) {
                             foreach ($addresses as $address) {
                                 $address['id_customer'] = $customer->id;
                                 unset($address['country'], $address['state'], $address['state_iso'], $address['id_address']);
                                 Db::getInstance()->insert('address', $address);
                             }
                         }
//.........这里部分代码省略.........
开发者ID:jicheng17,项目名称:vipinsg,代码行数:101,代码来源:AdminImportController.php


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