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


PHP Cart::nbProducts方法代码示例

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


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

示例1: initContent

 public function initContent()
 {
     parent::initContent();
     $log_on = Configuration::get('YA_ORG_LOGGING_ON');
     if (Tools::getValue('label')) {
         $data = explode('_', Tools::getValue('label'));
     } else {
         $data = explode('_', Tools::getValue('customerNumber'));
     }
     if (!empty($data) && isset($data[1])) {
         $ordernumber = $data['1'];
         $this->context->smarty->assign('ordernumber', $ordernumber);
         $this->context->smarty->assign('time', date('Y-m-d H:i:s '));
         if (!$ordernumber) {
             if ($log_on) {
                 $this->module->logSave('yakassa_success: Error ' . $this->module->l('Cart number is not specified'));
             }
             $this->setTemplate('error.tpl');
         } else {
             $cart = new Cart((int) $ordernumber);
             $qty = $cart->nbProducts();
             $this->context->smarty->assign('nbProducts', $qty);
             if (!Validate::isLoadedObject($cart) || $qty < 1) {
                 if ($log_on) {
                     $this->module->logSave('yakassa_success: Error ' . $this->module->l('Shopping cart does not exist'));
                 }
                 $this->setTemplate('error.tpl');
             } else {
                 $ordernumber = (int) $cart->id;
                 if (!$ordernumber) {
                     if ($log_on) {
                         $this->module->logSave('yakassa_success: Error ' . $this->module->l('Order number is not specified'));
                     }
                     $this->setTemplate('error.tpl');
                 } else {
                     $order = new Order((int) Order::getOrderByCartId($cart->id));
                     $customer = new Customer((int) $order->id_customer);
                     if ($order->hasBeenPaid()) {
                         if ($log_on) {
                             $this->module->logSave('yakassa_success: #' . $order->id . ' ' . $this->module->l('Order paid'));
                         }
                         Tools::redirectLink(__PS_BASE_URI__ . 'order-confirmation.php?key=' . $customer->secure_key . '&id_cart=' . (int) $order->id_cart . '&id_module=' . (int) $this->module->id . '&id_order=' . (int) $order->id);
                     } else {
                         if ($log_on) {
                             $this->module->logSave('yakassa_success: #' . $order->id . ' ' . $this->module->l('Order wait payment'));
                         }
                         $this->setTemplate('waitingPayment.tpl');
                     }
                 }
             }
         }
     } else {
         if ($log_on) {
             $this->module->logSave('yakassa_success: Error ' . $this->module->l('Cart number is not specified'));
         }
         $this->setTemplate('error.tpl');
     }
 }
开发者ID:KPG1,项目名称:yandex-money-cms-prestashop,代码行数:58,代码来源:success.php

示例2: confirmOrder

 public function confirmOrder($custom)
 {
     $cart = new Cart((int) $custom['id_cart']);
     $cart_details = $cart->getSummaryDetails(null, true);
     $cart_hash = sha1(serialize($cart->nbProducts()));
     $this->context->cart = $cart;
     $address = new Address((int) $cart->id_address_invoice);
     $this->context->country = new Country((int) $address->id_country);
     $this->context->customer = new Customer((int) $cart->id_customer);
     $this->context->language = new Language((int) $cart->id_lang);
     $this->context->currency = new Currency((int) $cart->id_currency);
     if (isset($cart->id_shop)) {
         $this->context->shop = new Shop($cart->id_shop);
     }
     $res = $this->getResult();
     if (strcmp($res, "VERIFIED") == 0) {
         $currency_decimals = is_array($this->context->currency) ? (int) $this->context->currency['decimals'] : (int) $this->context->currency->decimals;
         $this->decimals = $currency_decimals * _PS_PRICE_DISPLAY_PRECISION_;
         $message = null;
         $mc_gross = Tools::ps_round(Tools::getValue('mc_gross'), $this->decimals);
         $cart_details = $cart->getSummaryDetails(null, true);
         $shipping = $cart_details['total_shipping_tax_exc'];
         $subtotal = $cart_details['total_price_without_tax'] - $cart_details['total_shipping_tax_exc'];
         $tax = $cart_details['total_tax'];
         $total_price = Tools::ps_round($shipping + $subtotal + $tax, $this->decimals);
         if (bccomp($mc_gross, $total_price, 2) !== 0) {
             $payment = (int) Configuration::get('PS_OS_ERROR');
             $message = $this->l('Price paid on paypal is not the same that on PrestaShop.') . '<br />';
         } elseif ($custom['hash'] != $cart_hash) {
             $payment = (int) Configuration::get('PS_OS_ERROR');
             $message = $this->l('Cart changed, please retry.') . '<br />';
         } else {
             $payment = (int) Configuration::get('PS_OS_PAYMENT');
             $message = $this->l('Payment accepted.') . '<br />';
         }
         $customer = new Customer((int) $cart->id_customer);
         $transaction = PayPalOrder::getTransactionDetails(false);
         if (_PS_VERSION_ < '1.5') {
             $shop = null;
         } else {
             $shop_id = $this->context->shop->id;
             $shop = new Shop($shop_id);
         }
         $this->validateOrder($cart->id, $payment, $total_price, $this->displayName, $message, $transaction, $cart->id_currency, false, $customer->secure_key, $shop);
     }
 }
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:46,代码来源:notifier.php

示例3: confirmOrder

 public function confirmOrder($custom)
 {
     $cart = new Cart((int) $custom['id_cart']);
     $cart_details = $cart->getSummaryDetails(null, true);
     $cart_hash = sha1(serialize($cart->nbProducts()));
     $this->context->cart = $cart;
     $address = new Address((int) $cart->id_address_invoice);
     $this->context->country = new Country((int) $address->id_country);
     $this->context->customer = new Customer((int) $cart->id_customer);
     $this->context->language = new Language((int) $cart->id_lang);
     $this->context->currency = new Currency((int) $cart->id_currency);
     if (isset($cart->id_shop)) {
         $this->context->shop = new Shop($cart->id_shop);
     }
     $this->createLog($cart->getProducts(true));
     $mc_gross = Tools::getValue('mc_gross');
     $total_price = Tools::ps_round($cart_details['total_price'], 2);
     $message = null;
     $result = $this->verify();
     if (strcmp($result, VERIFIED) == 0) {
         if ($mc_gross != $total_price) {
             $payment = (int) Configuration::get('PS_OS_ERROR');
             $message = $this->l('Price payed on paypal is not the same that on PrestaShop.') . '<br />';
         } elseif ($custom['hash'] != $cart_hash) {
             $payment = (int) Configuration::get('PS_OS_ERROR');
             $message = $this->l('Cart changed, please retry.') . '<br />';
         } else {
             $payment = (int) Configuration::get('PS_OS_WS_PAYMENT');
             $message = $this->l('Payment accepted.') . '<br />';
         }
         $customer = new Customer((int) $cart->id_customer);
         $id_order = (int) Order::getOrderByCartId((int) $cart->id);
         $transaction = array('currency' => pSQL(Tools::getValue(CURRENCY)), 'id_invoice' => pSQL(Tools::getValue(ID_INVOICE)), 'id_transaction' => pSQL(Tools::getValue(ID_TRANSACTION)), 'payment_date' => pSQL(Tools::getValue(PAYMENT_DATE)), 'shipping' => (double) Tools::getValue(SHIPPING), 'total_paid' => (double) Tools::getValue(TOTAL_PAID));
         $this->validateOrder($cart->id, $payment, $total_price, $this->displayName, $message, $transaction, $cart->id_currency, false, $customer->secure_key);
         $history = new OrderHistory();
         $history->id_order = (int) $id_order;
         $history->changeIdOrderState((int) $payment, (int) $id_order);
         $history->addWithemail();
         $history->add();
     }
 }
开发者ID:rtajmahal,项目名称:PrestaShop-modules,代码行数:41,代码来源:notifier.php

示例4: 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) {
//.........这里部分代码省略.........
开发者ID:MacFlay,项目名称:Presta-Domowy,代码行数:101,代码来源:FrontController.php

示例5: intval

            $cart->id_customer = intval($cookie->id_customer);
        }
        $cart->id_currency = intval($cookie->id_currency);
        $cart->update();
    }
}
if (!isset($cart) or !$cart->id) {
    $cart = new Cart();
    $cart->id_lang = intval($cookie->id_lang);
    $cart->id_currency = intval($cookie->id_currency);
    $cart->id_guest = intval($cookie->id_guest);
    if ($cookie->id_customer) {
        $cart->id_customer = intval($cookie->id_customer);
    }
}
if (!$cart->nbProducts()) {
    $cart->id_carrier = NULL;
}
$ps_language = new Language(intval($cookie->id_lang));
setlocale(LC_COLLATE, strtolower($ps_language->iso_code) . '_' . strtoupper($ps_language->iso_code) . '.UTF-8');
setlocale(LC_CTYPE, strtolower($ps_language->iso_code) . '_' . strtoupper($ps_language->iso_code) . '.UTF-8');
setlocale(LC_NUMERIC, 'en_EN.UTF-8');
if (is_object($currency)) {
    $smarty->ps_currency = $currency;
}
if (is_object($ps_language)) {
    $smarty->ps_language = $ps_language;
}
$smarty->register_function('dateFormat', array('Tools', 'dateFormat'));
$smarty->register_function('productPrice', array('Product', 'productPrice'));
$smarty->register_function('convertPrice', array('Product', 'convertPrice'));
开发者ID:Bruno-2M,项目名称:prestashop,代码行数:31,代码来源:init.php

示例6: getLastCart

 public function getLastCart($with_order = true)
 {
     $carts = Cart::getCustomerCarts((int) $this->id, $with_order);
     if (!count($carts)) {
         return false;
     }
     $cart = array_shift($carts);
     $cart = new Cart((int) $cart['id_cart']);
     return $cart->nbProducts() === 0 ? (int) $cart->id : false;
 }
开发者ID:dev-lav,项目名称:htdocs,代码行数:10,代码来源:Customer.php

示例7: init


//.........这里部分代码省略.........
     }
     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))
     			{
     				$cookie->last_ref_source = 0;
     				$cookie->write();
     			}
     		}*/
     global $currency;
     $currency = Tools::setCurrency();
     $_MODULES = array();
     /* 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 (intval(Configuration::get('PS_GEOLOCATION_ENABLED')) and !in_array(strtoupper($cookie->iso_code_country), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES'))) and $cart->nbProducts() and intval(Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR')) != -1 and !self::isInWhitelistForGeolocation()) {
             unset($cookie->id_cart, $cart);
         } elseif ($cookie->id_customer != $cart->id_customer or $cookie->id_lang != $cart->id_lang or $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) or !$cart->id) {
         $this->checkIDS();
         $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) {
开发者ID:priyankajsr19,项目名称:shalu,代码行数:67,代码来源:FrontController.php

示例8: 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) {
//.........这里部分代码省略.........
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:101,代码来源:FrontController.php

示例9: hookPayment

 public function hookPayment($params)
 {
     if (!$this->active || !$this->checkCurrency($params['cart'])) {
         return;
     }
     $method = $this->useMobileMethod();
     $shop_url = PayPal::getShopDomainSsl(true, true);
     if (isset($this->context->cookie->express_checkout)) {
         // Check if user went through the payment preparation detail and completed it
         $detail = unserialize($this->context->cookie->express_checkout);
         if (!empty($detail['payer_id']) && !empty($detail['token'])) {
             $values = array('get_confirmation' => true);
             $link = $shop_url . _MODULE_DIR_ . $this->name . '/express_checkout/submit.php';
             if (_PS_VERSION_ < '1.5') {
                 Tools::redirectLink($link . '?' . http_build_query($values, '', '&'));
             } else {
                 $controller = new FrontController();
                 $controller->init();
                 Tools::redirect(Context::getContext()->link->getModuleLink('paypal', 'confirm', $values));
             }
         }
     }
     $this->context->smarty->assign(array('logos' => $this->paypal_logos->getLogos(), 'sandbox_mode' => Configuration::get('PAYPAL_SANDBOX'), 'use_mobile' => (bool) $this->context->getMobileDevice(), 'PayPal_lang_code' => isset($iso_lang[$this->context->language->iso_code]) ? $iso_lang[$this->context->language->iso_code] : 'en_US'));
     if ($method == HSS) {
         $billing_address = new Address($this->context->cart->id_address_invoice);
         $delivery_address = new Address($this->context->cart->id_address_delivery);
         $billing_address->country = new Country($billing_address->id_country);
         $delivery_address->country = new Country($delivery_address->id_country);
         $billing_address->state = new State($billing_address->id_state);
         $delivery_address->state = new State($delivery_address->id_state);
         $cart = new Cart((int) $this->context->cart->id);
         $cart_details = $cart->getSummaryDetails(null, true);
         // Backward compatibility
         if (_PS_VERSION_ < '1.5') {
             $shipping = $this->context->cart->getOrderShippingCost();
         } else {
             $shipping = $this->context->cart->getTotalShippingCost();
         }
         if ((int) Configuration::get('PAYPAL_SANDBOX') == 1) {
             $action_url = 'https://securepayments.sandbox.paypal.com/acquiringweb';
         } else {
             $action_url = 'https://securepayments.paypal.com/acquiringweb';
         }
         $this->context->smarty->assign(array('action_url' => $action_url, 'cart' => $this->context->cart, 'cart_details' => $cart_details, 'currency' => new Currency((int) $this->context->cart->id_currency), 'customer' => $this->context->customer, 'business_account' => Configuration::get('PAYPAL_BUSINESS_ACCOUNT'), 'custom' => Tools::jsonEncode(array('id_cart' => $this->context->cart->id, 'hash' => sha1(serialize($cart->nbProducts())))), 'gift_price' => (double) Configuration::get('PS_GIFT_WRAPPING_PRICE'), 'billing_address' => $billing_address, 'delivery_address' => $delivery_address, 'shipping' => $shipping, 'subtotal' => $cart_details['total_price_without_tax'] - $shipping, 'time' => time(), 'cancel_return' => $this->context->link->getPageLink('order.php'), 'notify_url' => $shop_url . _MODULE_DIR_ . $this->name . '/integral_evolution/notifier.php', 'return_url' => $shop_url . _MODULE_DIR_ . $this->name . '/integral_evolution/submit.php?id_cart=' . (int) $this->context->cart->id, 'tracking_code' => $this->getTrackingCode()));
         return $this->fetchTemplate('/views/templates/front/integral_evolution/', 'iframe');
     } elseif ($method == WPS || $method == ECS) {
         $this->getTranslations();
         $this->context->smarty->assign(array('PayPal_integral' => WPS, 'PayPal_express_checkout' => ECS, 'PayPal_payment_method' => $method, 'PayPal_payment_type' => 'payment_cart', 'PayPal_current_shop_url' => $shop_url . $_SERVER['REQUEST_URI'], 'PayPal_tracking_code' => $this->getTrackingCode()));
         return $this->fetchTemplate('/views/templates/front/express_checkout/', 'paypal');
     }
     return '';
 }
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:52,代码来源:paypal_abstract.php


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