本文整理汇总了PHP中Customer::isBanned方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::isBanned方法的具体用法?PHP Customer::isBanned怎么用?PHP Customer::isBanned使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Customer
的用法示例。
在下文中一共展示了Customer::isBanned方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pathinfo
global $cart, $cookie, $_CONF, $link;
/* get page name to display it in body id */
$pathinfo = pathinfo(__FILE__);
$page_name = basename($_SERVER['PHP_SELF'], '.' . $pathinfo['extension']);
$page_name = preg_match('/^[0-9]/', $page_name) ? 'page_' . $page_name : $page_name;
// Init Cookie
$cookie = new Cookie('ps');
// Switch language if needed and init cookie language
if ($iso = Tools::getValue('isolang') and Validate::isLanguageIsoCode($iso) and $id_lang = intval(Language::getIdByIso($iso))) {
$_GET['id_lang'] = $id_lang;
}
Tools::switchLanguage();
Tools::setCookieLanguage();
/* attribute id_lang is often needed, so we create a constant for performance reasons */
define('_USER_ID_LANG_', intval($cookie->id_lang));
if (isset($_GET['logout']) or $cookie->logged and Customer::isBanned(intval($cookie->id_customer))) {
$cookie->logout();
Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL);
} elseif (isset($_GET['mylogout'])) {
$cookie->mylogout();
Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL);
}
$iso = strtolower(Language::getIsoById($cookie->id_lang ? intval($cookie->id_lang) : 1));
@(include _PS_TRANSLATIONS_DIR_ . $iso . '/fields.php');
@(include _PS_TRANSLATIONS_DIR_ . $iso . '/errors.php');
$_MODULES = array();
$currency = Tools::setCurrency();
if (is_numeric($cookie->id_cart)) {
$cart = new Cart(intval($cookie->id_cart));
$cart->id_lang = intval($cookie->id_lang);
if ($cart->OrderExists()) {
示例2: init
public function init()
{
/*
* Globals are DEPRECATED as of version 1.5.
* Use the Context to access objects instead.
* Example: $this->context->cart
*/
global $useSSL, $cookie, $smarty, $cart, $iso, $defaultCountry, $protocol_link, $protocol_content, $link, $css_files, $js_files, $currency;
if (self::$initialized) {
return;
}
self::$initialized = true;
parent::init();
// If current URL use SSL, set it true (used a lot for module redirect)
if (Tools::usingSecureMode()) {
$useSSL = true;
}
// For compatibility with globals, DEPRECATED as of version 1.5
$css_files = $this->css_files;
$js_files = $this->js_files;
// If we call a SSL controller without SSL or a non SSL controller with SSL, we redirect with the right protocol
if (Configuration::get('PS_SSL_ENABLED') && $_SERVER['REQUEST_METHOD'] != 'POST' && $this->ssl != Tools::usingSecureMode()) {
header('HTTP/1.1 301 Moved Permanently');
header('Cache-Control: no-cache');
if ($this->ssl) {
header('Location: ' . Tools::getShopDomainSsl(true) . $_SERVER['REQUEST_URI']);
} else {
header('Location: ' . Tools::getShopDomain(true) . $_SERVER['REQUEST_URI']);
}
exit;
}
if ($this->ajax) {
$this->display_header = false;
$this->display_footer = false;
}
// if account created with the 2 steps register process, remove 'accoun_created' from cookie
if (isset($this->context->cookie->account_created)) {
$this->context->smarty->assign('account_created', 1);
unset($this->context->cookie->account_created);
}
ob_start();
// Init cookie language
// @TODO This method must be moved into switchLanguage
Tools::setCookieLanguage($this->context->cookie);
$protocol_link = Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode() ? 'https://' : 'http://';
$useSSL = isset($this->ssl) && $this->ssl && Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode() ? true : false;
$protocol_content = $useSSL ? 'https://' : 'http://';
$link = new Link($protocol_link, $protocol_content);
$this->context->link = $link;
if ($id_cart = (int) $this->recoverCart()) {
$this->context->cookie->id_cart = (int) $id_cart;
}
if ($this->auth && !$this->context->customer->isLogged($this->guestAllowed)) {
Tools::redirect('index.php?controller=authentication' . ($this->authRedirection ? '&back=' . $this->authRedirection : ''));
}
/* Theme is missing */
if (!is_dir(_PS_THEME_DIR_)) {
throw new PrestaShopException(sprintf(Tools::displayError('Current theme unavailable "%s". Please check your theme directory name and permissions.'), basename(rtrim(_PS_THEME_DIR_, '/\\'))));
}
if (Configuration::get('PS_GEOLOCATION_ENABLED')) {
if (($newDefault = $this->geolocationManagement($this->context->country)) && Validate::isLoadedObject($newDefault)) {
$this->context->country = $newDefault;
}
}
$currency = Tools::setCurrency($this->context->cookie);
if (isset($_GET['logout']) || $this->context->customer->logged && Customer::isBanned($this->context->customer->id)) {
$this->context->customer->logout();
Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
} elseif (isset($_GET['mylogout'])) {
$this->context->customer->mylogout();
Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
}
/* Cart already exists */
if ((int) $this->context->cookie->id_cart) {
$cart = new Cart($this->context->cookie->id_cart);
if ($cart->OrderExists()) {
unset($this->context->cookie->id_cart, $cart, $this->context->cookie->checkedTOS);
$this->context->cookie->check_cgv = false;
} elseif (intval(Configuration::get('PS_GEOLOCATION_ENABLED')) && !in_array(strtoupper($this->context->cookie->iso_code_country), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES'))) && $cart->nbProducts() && intval(Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR')) != -1 && !FrontController::isInWhitelistForGeolocation() && !in_array($_SERVER['SERVER_NAME'], array('localhost', '127.0.0.1'))) {
unset($this->context->cookie->id_cart, $cart);
} elseif ($this->context->cookie->id_customer != $cart->id_customer || $this->context->cookie->id_lang != $cart->id_lang || $currency->id != $cart->id_currency) {
if ($this->context->cookie->id_customer) {
$cart->id_customer = (int) $this->context->cookie->id_customer;
}
$cart->id_lang = (int) $this->context->cookie->id_lang;
$cart->id_currency = (int) $currency->id;
$cart->update();
}
/* Select an address if not set */
if (isset($cart) && (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0 || !isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) && $this->context->cookie->id_customer) {
$to_update = false;
if (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0) {
$to_update = true;
$cart->id_address_delivery = (int) Address::getFirstCustomerAddressId($cart->id_customer);
}
if (!isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) {
$to_update = true;
$cart->id_address_invoice = (int) Address::getFirstCustomerAddressId($cart->id_customer);
}
if ($to_update) {
//.........这里部分代码省略.........
示例3: hookdisplayAdminCustomers
public function hookdisplayAdminCustomers($params)
{
if (!$this->active) {
return;
}
$xAux0 = Configuration::get('EKO_SMS_OP');
$xAux1 = Configuration::get('EKO_SMS_USERNAME');
$xAux2 = Configuration::get('EKO_SMS_PASSWORD');
if (empty($xAux0) or empty($xAux1) or empty($xAux2)) {
$this->smarty->assign(array('status' => 2, 'callfrom' => 2, 'SMSerror' => $this->l('SMS Module not Configured!')));
} else {
$customer = new Customer($params['id_customer']);
if (!$customer->isBanned($params['id_customer']) and $customer->getAddressesTotalById($params['id_customer']) > 0) {
$this->smarty->assign(array('status' => 1, 'callfrom' => 2, 'id_customer' => $params['id_customer'], 'id_order' => 0, 'pathSMS' => tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->name . '/ajax' . $this->name . '.php'));
} else {
$this->smarty->assign(array('status' => 2, 'callfrom' => 2, 'SMSerror' => $this->l('This user can not receive SMS!')));
}
}
return $this->display(__FILE__, '/sms.tpl');
}
示例4: _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;
}
示例5: _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;
}
示例6: init
public function init()
{
global $cookie, $smarty, $cart, $iso, $defaultCountry, $protocol_link, $protocol_content, $link, $css_files, $js_files;
if (self::$initialized) {
return;
}
self::$initialized = true;
$css_files = array();
$js_files = array();
if ($this->ssl and (empty($_SERVER['HTTPS']) or strtolower($_SERVER['HTTPS']) == 'off') and Configuration::get('PS_SSL_ENABLED')) {
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . Tools::getShopDomainSsl(true) . $_SERVER['REQUEST_URI']);
exit;
}
ob_start();
/* Loading default country */
$defaultCountry = new Country((int) Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT'));
$cookie = new Cookie('ps');
$link = new Link();
if ($this->auth and !$cookie->isLogged($this->guestAllowed)) {
Tools::redirect('authentication.php' . ($this->authRedirection ? '?back=' . $this->authRedirection : ''));
}
/* Theme is missing or maintenance */
if (!is_dir(_PS_THEME_DIR_)) {
die(Tools::displayError('Current theme unavailable. Please check your theme directory name and permissions.'));
} elseif (basename($_SERVER['PHP_SELF']) != 'disabled.php' and !(int) Configuration::get('PS_SHOP_ENABLE')) {
$this->maintenance = true;
} elseif (Configuration::get('PS_GEOLOCATION_ENABLED')) {
if (!isset($cookie->iso_code_country)) {
if ($cookie->logged) {
$id_country = Customer::getCurrentCountry((int) $cookie->id_customer);
$cookie->iso_code_country = Country::getIsoById($id_country);
} else {
$this->geolocationManagement();
}
}
if (!isset($cookie->iso_code_country)) {
$current_country_id = Customer::getCurrentCountry((int) $cookie->id_customer);
} else {
$current_country_id = Country::getByIso($cookie->iso_code_country);
}
$current_country = new Country($current_country_id, 1);
$cookie->id_country = $current_country->id;
$smarty->assign('current_country', $current_country->name);
$smarty->assign('current_country_id', $current_country->id);
if ($cookie->id_country == 110 && !isset($cookie->id_currency)) {
$cookie->id_currency = 4;
}
}
//set imagesize if not set
if (!isset($cookie->image_size)) {
$cookie->image_size = IMAGE_SIZE_LARGE;
$cookie->write();
}
if (!isset($cookie->greetings) && !$cookie->logged) {
$cookie->greetings = 1;
$cookie->write();
$smarty->assign('show_greetings', 1);
}
//echo $cookie->image_size;
if ($image_size = Tools::getValue("is")) {
if ($image_size == "s" && $cookie->image_size == IMAGE_SIZE_LARGE) {
$cookie->image_size = IMAGE_SIZE_SMALL;
$cookie->write();
} else {
if ($image_size == "l" && $cookie->image_size == IMAGE_SIZE_SMALL) {
$cookie->image_size = IMAGE_SIZE_LARGE;
$cookie->write();
}
}
}
// Switch language if needed and init cookie language
if ($iso = Tools::getValue('isolang') and Validate::isLanguageIsoCode($iso) and $id_lang = (int) Language::getIdByIso($iso)) {
$_GET['id_lang'] = $id_lang;
}
Tools::switchLanguage();
Tools::setCookieLanguage();
/* attribute id_lang is often needed, so we create a constant for performance reasons */
if (!defined('_USER_ID_LANG_')) {
define('_USER_ID_LANG_', (int) $cookie->id_lang);
}
if (isset($_GET['logout']) or $cookie->logged and Customer::isBanned((int) $cookie->id_customer)) {
$cookie->logout();
Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL);
} elseif (isset($_GET['mylogout'])) {
$this->logoutFacebook();
$cookie->mylogout();
Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL);
}
if ($source = Tools::getValue('utm_source')) {
$cookie->last_source = $source;
$cookie->write();
}
if ($ref_source = Tools::getValue('vbref')) {
$cookie->last_ref_source = $ref_source;
$cookie->write();
}
/*else
{
if(!isset($cookie->last_ref_source))
//.........这里部分代码省略.........
示例7: init
public function init()
{
global $useSSL, $cookie, $smarty, $cart, $iso, $defaultCountry, $protocol_link, $protocol_content, $link, $css_files, $js_files;
if (self::$initialized) {
return;
}
self::$initialized = true;
// If current URL use SSL, set it true (used a lot for module redirect)
if (Tools::usingSecureMode()) {
$useSSL = $this->ssl = true;
}
$css_files = array();
$js_files = array();
if ($this->ssl && !Tools::usingSecureMode() && _PS_SSL_ENABLED_) {
header('HTTP/1.1 301 Moved Permanently');
header('Cache-Control: no-cache');
header('Location: ' . Tools::getShopDomainSsl(true) . $_SERVER['REQUEST_URI']);
exit;
} elseif (_PS_SSL_ENABLED_ && Tools::usingSecureMode() && !$this->ssl) {
header('HTTP/1.1 301 Moved Permanently');
header('Cache-Control: no-cache');
header('Location: ' . Tools::getShopDomain(true) . $_SERVER['REQUEST_URI']);
exit;
}
ob_start();
/* Loading default country */
$defaultCountry = new Country((int) _PS_COUNTRY_DEFAULT_, (int) _PS_LANG_DEFAULT_);
$cookie = new Cookie('ps', '', time() + ((int) Configuration::get('PS_COOKIE_LIFETIME_FO') > 0 ? (int) Configuration::get('PS_COOKIE_LIFETIME_FO') : 1) * 3600);
$link = new Link();
if ($this->auth && !$cookie->isLogged($this->guestAllowed)) {
Tools::redirect('authentication.php' . ($this->authRedirection ? '?back=' . $this->authRedirection : ''));
}
/* Theme is missing or maintenance */
if (!file_exists(_PS_THEME_DIR_)) {
die(Tools::displayError('Current theme unavailable. Please check your theme directory name and permissions.'));
} elseif (basename($_SERVER['PHP_SELF']) != 'disabled.php' && !(int) Configuration::get('PS_SHOP_ENABLE')) {
$this->maintenance = true;
} elseif (_PS_GEOLOCATION_ENABLED_) {
$this->geolocationManagement();
}
// Switch language if needed and init cookie language
$iso = Tools::getValue('isolang');
if ($iso && Validate::isLanguageIsoCode($iso)) {
$id_lang = (int) Language::getIdByIso($iso);
if ($id_lang) {
$_GET['id_lang'] = $id_lang;
}
}
Tools::switchLanguage();
Tools::setCookieLanguage();
/* attribute id_lang is often needed, so we create a constant for performance reasons */
if (!defined('_USER_ID_LANG_')) {
define('_USER_ID_LANG_', (int) $cookie->id_lang);
}
if (isset($_GET['logout']) || $cookie->logged && Customer::isBanned((int) $cookie->id_customer)) {
$cookie->logout();
Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
} elseif (isset($_GET['mylogout'])) {
$cookie->mylogout();
Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
}
global $currency;
$currency = Tools::setCurrency();
/* Cart already exists */
if ((int) $cookie->id_cart) {
$cart = new Cart((int) $cookie->id_cart);
if ($cart->OrderExists()) {
unset($cookie->id_cart, $cart, $cookie->checkedTOS);
} elseif (_PS_GEOLOCATION_ENABLED_ && !in_array(strtoupper($cookie->iso_code_country), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES'))) && $cart->nbProducts() && (int) Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR') != -1 && !self::isInWhitelistForGeolocation()) {
unset($cookie->id_cart, $cart);
} elseif ($cookie->id_customer != $cart->id_customer || $cookie->id_lang != $cart->id_lang || $cookie->id_currency != $cart->id_currency) {
if ($cookie->id_customer) {
$cart->id_customer = (int) $cookie->id_customer;
}
$cart->id_lang = (int) $cookie->id_lang;
$cart->id_currency = (int) $cookie->id_currency;
$cart->update();
}
/* Select an address if not set */
if (isset($cart) && (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0 || !isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) && $cookie->id_customer) {
$to_update = false;
if (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0) {
$to_update = true;
$cart->id_address_delivery = (int) Address::getFirstCustomerAddressId($cart->id_customer);
}
if (!isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) {
$to_update = true;
$cart->id_address_invoice = (int) Address::getFirstCustomerAddressId($cart->id_customer);
}
if ($to_update) {
$cart->update();
}
}
}
if (!isset($cart) || !$cart->id) {
$cart = new Cart();
$cart->id_lang = (int) $cookie->id_lang;
$cart->id_currency = (int) $cookie->id_currency;
$cart->id_guest = (int) $cookie->id_guest;
if ($cookie->id_customer) {
//.........这里部分代码省略.........
示例8: init
/**
* Initializes front controller: sets smarty variables,
* class properties, redirects depending on context, etc.
*
* @global bool $useSSL SSL connection flag
* @global Cookie $cookie Visitor's cookie
* @global Smarty $smarty
* @global Cart $cart Visitor's cart
* @global string $iso Language ISO
* @global Country $defaultCountry Visitor's country object
* @global string $protocol_link
* @global string $protocol_content
* @global Link $link
* @global array $css_files
* @global array $js_files
* @global Currency $currency Visitor's selected currency
*
* @throws PrestaShopException
*/
public function init()
{
/*
* Globals are DEPRECATED as of version 1.5.0.1
* Use the Context object to access objects instead.
* Example: $this->context->cart
*/
global $useSSL, $cookie, $smarty, $cart, $iso, $defaultCountry, $protocol_link, $protocol_content, $link, $css_files, $js_files, $currency;
if (self::$initialized) {
return;
}
self::$initialized = true;
parent::init();
// enable Symfony error handler if debug mode enabled
$this->initDebugguer();
// If current URL use SSL, set it true (used a lot for module redirect)
if (Tools::usingSecureMode()) {
$useSSL = true;
}
// For compatibility with globals, DEPRECATED as of version 1.5.0.1
$css_files = $this->css_files;
$js_files = $this->js_files;
$this->sslRedirection();
if ($this->ajax) {
$this->display_header = false;
$this->display_footer = false;
}
// If account created with the 2 steps register process, remove 'account_created' from cookie
if (isset($this->context->cookie->account_created)) {
unset($this->context->cookie->account_created);
}
ob_start();
// Init cookie language
// @TODO This method must be moved into switchLanguage
Tools::setCookieLanguage($this->context->cookie);
$protocol_link = Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode() ? 'https://' : 'http://';
$useSSL = isset($this->ssl) && $this->ssl && Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode() ? true : false;
$protocol_content = $useSSL ? 'https://' : 'http://';
$link = new Link($protocol_link, $protocol_content);
$this->context->link = $link;
if ($id_cart = (int) $this->recoverCart()) {
$this->context->cookie->id_cart = (int) $id_cart;
}
if ($this->auth && !$this->context->customer->isLogged()) {
Tools::redirect('index.php?controller=authentication' . ($this->authRedirection ? '&back=' . $this->authRedirection : ''));
}
/* Theme is missing */
if (!is_dir(_PS_THEME_DIR_)) {
throw new PrestaShopException(sprintf(Tools::displayError('Current theme unavailable "%s". Please check your theme directory name and permissions.'), basename(rtrim(_PS_THEME_DIR_, '/\\'))));
}
if (Configuration::get('PS_GEOLOCATION_ENABLED')) {
if (($new_default = $this->geolocationManagement($this->context->country)) && Validate::isLoadedObject($new_default)) {
$this->context->country = $new_default;
}
} elseif (Configuration::get('PS_DETECT_COUNTRY')) {
$has_currency = isset($this->context->cookie->id_currency) && (int) $this->context->cookie->id_currency;
$has_country = isset($this->context->cookie->iso_code_country) && $this->context->cookie->iso_code_country;
$has_address_type = false;
if ((int) $this->context->cookie->id_cart && ($cart = new Cart($this->context->cookie->id_cart)) && Validate::isLoadedObject($cart)) {
$has_address_type = isset($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) && $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')};
}
if ((!$has_currency || $has_country) && !$has_address_type) {
$id_country = $has_country && !Validate::isLanguageIsoCode($this->context->cookie->iso_code_country) ? (int) Country::getByIso(strtoupper($this->context->cookie->iso_code_country)) : (int) Tools::getCountry();
$country = new Country($id_country, (int) $this->context->cookie->id_lang);
if (!$has_currency && validate::isLoadedObject($country) && $this->context->country->id !== $country->id) {
$this->context->country = $country;
$this->context->cookie->id_currency = (int) Currency::getCurrencyInstance($country->id_currency ? (int) $country->id_currency : (int) Configuration::get('PS_CURRENCY_DEFAULT'))->id;
$this->context->cookie->iso_code_country = strtoupper($country->iso_code);
}
}
}
$currency = Tools::setCurrency($this->context->cookie);
if (isset($_GET['logout']) || $this->context->customer->logged && Customer::isBanned($this->context->customer->id)) {
$this->context->customer->logout();
Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
} elseif (isset($_GET['mylogout'])) {
$this->context->customer->mylogout();
Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
}
/* Cart already exists */
if ((int) $this->context->cookie->id_cart) {
//.........这里部分代码省略.........
示例9: 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;
}