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


PHP State::getNameById方法代码示例

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


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

示例1: execPayment

 function execPayment($cart)
 {
     global $cart;
     global $smarty;
     $invoice_address = new Address((int) $cart->id_address_invoice);
     if ($invoice_address->id_country == 110) {
         return;
     }
     $curr_currency = CurrencyCore::getCurrency($cart->id_currency);
     if ((int) $curr_currency['paypal_support'] === 1) {
         return;
     }
     $delivery = new Address(intval($cart->id_address_delivery));
     $invoice = new Address(intval($cart->id_address_invoice));
     $customer = new Customer(intval($cart->id_customer));
     global $cookie, $smarty;
     //Verify currencies and display payment form
     $currencies = Currency::getCurrencies();
     $authorized_currencies = array_flip(explode(',', $this->currencies));
     $currencies_used = array();
     foreach ($currencies as $key => $currency) {
         if (isset($authorized_currencies[$currency['id_currency']])) {
             $currencies_used[] = $currencies[$key];
         }
     }
     $smarty->assign('currencies_used', $currencies_used);
     $products = $cart->getProducts();
     foreach ($products as $key => $product) {
         $products[$key]['name'] = str_replace('"', '\'', $product['name']);
         $products[$key]['name'] = htmlentities(utf8_decode($product['name']));
     }
     $CheckoutUrl = 'https://www.2checkout.com/checkout/spurchase';
     $x_receipt_link_url = 'http://' . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . 'modules/checkout/validation.php';
     $sid = Configuration::get('CHECKOUT_SID');
     $total = number_format($cart->getOrderTotal(true, 3), 0, '.', '');
     $cart_order_id = $cart->id;
     $email = $customer->email;
     $secure_key = $customer->secure_key;
     $demo = "Y";
     // Change to "Y" for demo mode
     $outside_state = "XX";
     // This will pre-select Outside USA and Canada, if state does not exist
     // Invoice Parameters
     $card_holder_name = $invoice->firstname . ' ' . $invoice->lastname;
     $street_address = $invoice->address1;
     $street_address2 = $invoice->address2;
     $phone = $invoice->phone_mobile;
     $city = $invoice->city;
     $state = (Validate::isLoadedObject($invoice) and $invoice->id_state) ? new State(intval($invoice->id_state)) : false;
     $zip = $invoice->postcode;
     $country = $invoice->country;
     // Shipping Parameters
     $ship_name = $delivery->firstname . ' ' . $invoice->lastname;
     $ship_street_address = $delivery->address1;
     $ship_street_address2 = $delivery->address2;
     $ship_city = $delivery->city;
     $ship_state = (Validate::isLoadedObject($delivery) and $delivery->id_state) ? new State(intval($delivery->id_state)) : false;
     $ship_zip = $delivery->postcode;
     $ship_country = $delivery->country;
     if ($cart->id_currency != 2) {
         $total = Tools::convertPrice($total, $cart->id_currency, false);
         $this_currency = CurrencyCore::getCurrency($cart->id_currency);
         $curr_conversion_msg = "<p>Dear Customer, we do not accept payments in <b>{$this_currency['name']}</b>, we will process the equivalent amount of <b>" . Tools::displayPrice($total, 2) . "</b> in USD(United States Dollar).</p> <p>The currency conversion rates are provided by openexchangerates.org</p>";
         $smarty->assign("curr_conversion_msg", $curr_conversion_msg);
     }
     $total = round($total);
     $smarty->assign(array('CheckoutUrl' => $CheckoutUrl, 'return_url' => $return_url, 'sid' => $sid, 'total' => $total, 'cart_order_id' => $cart_order_id, 'email' => $email, 'demo' => $demo, 'outside_state' => $outside_state, 'secure_key' => $secure_key, 'card_holder_name' => $card_holder_name, 'street_address' => $street_address, 'street_address2' => $street_address2, 'phone' => $phone, 'city' => $city, 'state' => $state, 'zip' => $zip, 'country' => $country, 'ship_name' => $ship_name, 'ship_street_address' => $ship_street_address, 'ship_street_address2' => $ship_street_address2, 'ship_city' => $ship_city, 'ship_state' => $ship_state, 'ship_zip' => $ship_zip, 'ship_country' => $ship_country, 'products' => $products, 'x_receipt_link_url' => $x_receipt_link_url, 'TotalAmount' => number_format($total), 'this_path' => $this->_path, 'this_path_ssl' => Configuration::get('PS_FO_PROTOCOL') . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . "modules/{$this->name}/"));
     /* Complementos */
     $cart = new Cart($cookie->id_cart);
     $address = new Address($cart->id_address_delivery, intval($cookie->id_lang));
     $state = State::getNameById($address->id_state);
     $state = $state ? '(' . $state . ')' : '';
     $str_address = ($address->company ? $address->company . '<br>' : '') . $address->firstname . ' ' . $address->lastname . '<br>' . $address->address1 . '<br>' . ($address->address2 ? $address->address2 . '<br>' : '') . $address->postcode . ' ' . $address->city . '<br>' . $address->country . $state;
     $smarty->assign('address', $str_address);
     $carrier = Carrier::getCarriers(intval($cookie->id_lang));
     if ($carrier) {
         foreach ($carrier as $c) {
             if ($cart->id_carrier == $c[id_carrier]) {
                 $smarty->assign('carrier', $c['name']);
                 break;
             }
         }
     }
     /* FIN Complementos */
     return $this->display(__FILE__, 'payment_execution.tpl');
 }
开发者ID:priyankajsr19,项目名称:indusdiva2,代码行数:86,代码来源:checkout.php

示例2: 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

示例3: hookPayment

 public function hookPayment($params)
 {
     global $cookie;
     $this->_validateErrors = array();
     session_start();
     $_SESSION['params1'] = '';
     $_SESSION['cart_currency'] = '';
     $_SESSION['cart_amount'] = '';
     $_SESSION['params1'] = $params;
     if (!$this->active) {
         return;
     }
     global $smarty;
     $address = new Address(intval($params['cart']->id_address_invoice));
     $customer = new Customer(intval($params['cart']->id_customer));
     $merchant_id = trim(Configuration::get('CCAVENUE_MERCHANT_ID'));
     $access_code = trim(Configuration::get('CCAVENUE_ACCESS_CODE'));
     $encryption_key = trim(Configuration::get('CCAVENUE_ENCRYPTION_KEY'));
     $ccavenue_title = trim(Configuration::get('CCAVENUE_TITLE'));
     $Redirect_Url = 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/ccavenue/validation.php';
     $Cancel_Url = 'http://' . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/ccavenue/validation.php';
     $language = 'EN';
     $currency = $this->getCurrency('INR');
     $OrderId = date('Ymdhis') . '-' . intval($params['cart']->id);
     $Amount = $params['cart']->getOrderTotal(true, 3);
     $_SESSION['cart_amount'] = $Amount;
     $default_currency_support_ccavnenue = 'INR';
     $default_currency_id = Db::getInstance()->getValue("\n\t\t\t\t\t\tSELECT `id_currency`\n\t\t\t\t\t\tFROM `" . _DB_PREFIX_ . "currency`\n\t\t\t\t\t\tWHERE `iso_code` = '" . $default_currency_support_ccavnenue . "'");
     $base_currency_id = Configuration::get('PS_CURRENCY_DEFAULT');
     $default_currency = new Currency((int) $default_currency_id);
     $base_currency = new Currency((int) $base_currency_id);
     $base_currency_code = $base_currency->iso_code;
     $current_currency = new Currency((int) $params['cart']->id_currency);
     $_SESSION['cart_currency'] = $params['cart']->id_currency;
     $current_currency_code = $current_currency->iso_code;
     $billing_name = $address->firstname . $address->lastname;
     $billing_address = $address->address1 . $address->address2;
     $billing_city = $address->city;
     $billing_zip = $address->postcode;
     $billing_tel = $address->phone;
     $billing_email = $customer->email;
     $country = new Country(intval($address->id_country));
     $state = new State(intval($address->id_state));
     $billing_state = $state->getNameById($address->id_state);
     $land_id = $params['cart']->id_lang;
     $billing_country = $country->getNameById($land_id, $address->id_country);
     $merchant_param1 = (int) $params['cart']->id;
     $merchant_param2 = date('YmdHis');
     $merchant_param3 = $params['cart']->secure_key;
     $cust_notes_message = Message::getMessageByCartId(intval($params['cart']->id));
     $cust_notes = $cust_notes_message['message'];
     $billing_cust_notes = $cust_notes;
     $delivery_name = '';
     $delivery_address = '';
     $delivery_city = '';
     $delivery_state = '';
     $delivery_tel = '';
     $delivery_zip = '';
     $delivery_country = '';
     $delivery_name = $address->firstname . $address->lastname;
     $delivery_address = $address->address1 . $address->address2;
     $delivery_city = $address->city;
     $delivery_zip = $address->postcode;
     $delivery_tel = $address->phone;
     $delivery_state = $billing_state;
     $delivery_country = $billing_country;
     $merchant_data_array = array();
     $merchant_data_array['merchant_id'] = $merchant_id;
     $merchant_data_array['order_id'] = $OrderId;
     $merchant_data_array['currency'] = 'INR';
     $merchant_data_array['amount'] = $Amount;
     $merchant_data_array['redirect_url'] = $Redirect_Url;
     $merchant_data_array['cancel_url'] = $Cancel_Url;
     $merchant_data_array['language'] = $language;
     $merchant_data_array['billing_name'] = $billing_name;
     $merchant_data_array['billing_address'] = $billing_address;
     $merchant_data_array['billing_city'] = $billing_city;
     $merchant_data_array['billing_state'] = $billing_state;
     $merchant_data_array['billing_zip'] = $billing_zip;
     $merchant_data_array['billing_country'] = $billing_country;
     $merchant_data_array['billing_tel'] = $billing_tel;
     $merchant_data_array['billing_email'] = $billing_email;
     $merchant_data_array['delivery_name'] = $delivery_name;
     $merchant_data_array['delivery_address'] = $delivery_address;
     $merchant_data_array['delivery_city'] = $delivery_city;
     $merchant_data_array['delivery_state'] = $delivery_state;
     $merchant_data_array['delivery_zip'] = $delivery_zip;
     $merchant_data_array['delivery_country'] = $delivery_country;
     $merchant_data_array['delivery_tel'] = $delivery_tel;
     $merchant_data_array['merchant_param1'] = $merchant_param1;
     $merchant_data_array['merchant_param2'] = $merchant_param2;
     $merchant_data_array['merchant_param3'] = $merchant_param3;
     $merchant_data = implode("&", $merchant_data_array);
     $ccavenue_post_data = '';
     $ccavenue_post_data_array = array();
     foreach ($merchant_data_array as $key => $value) {
         $ccavenue_post_data_array[] .= $key . '=' . urlencode($value);
     }
     $ccavenue_post_data = implode("&", $ccavenue_post_data_array);
     $encrypted_data = $this->encrypt($ccavenue_post_data, $encryption_key);
//.........这里部分代码省略.........
开发者ID:ac3gam3r,项目名称:Maxokraft,代码行数:101,代码来源:ccavenue.php

示例4: getAddress

 public static function getAddress(Address $address)
 {
     return array('first_name' => $address->firstname, 'last_name' => $address->lastname, 'phone' => $address->phone, 'alt_phone' => $address->phone_mobile, 'street' => $address->address1, 'address_addition' => $address->address2, 'city' => $address->city, 'state' => State::getNameById($address->id_state), 'country' => Country::getIsoById($address->id_country), 'postcode' => $address->postcode);
 }
开发者ID:aplazame,项目名称:prestashop,代码行数:4,代码来源:Serializers.php

示例5: hookPayment

 public function hookPayment($params)
 {
     global $cart;
     global $smarty, $cart, $cookie;
     $invoice_address = new Address((int) $cart->id_address_invoice);
     $key = Configuration::get('PAYU_MERCHANT_ID');
     $salt = Configuration::get('PAYU_SALT');
     if (!$this->active) {
         return;
     }
     $mode = Configuration::get('PAYU_MODE');
     $log = Configuration::get('PAYU_LOGS');
     $amount = $cart->getOrderTotal(true, Cart::BOTH);
     $curr_currency = CurrencyCore::getCurrency($cart->id_currency);
     if ($invoice_address->id_country == 110) {
         $key = 'VLBB6Z';
         $salt = 'KQUxLUkT';
         if ($cart->id_currency != 4) {
             //convert to USD(default)
             $amount = Tools::convertPrice($amount, $cart->id_currency, false);
             //convert to INT
             $amount = Tools::convertPrice($amount, 4);
             $inr_currency = CurrencyCore::getCurrency(4);
             $curr_conversion_msg = "<p>Dear Customer, any order with an Indian billing address entails processing of the order value in {$inr_currency['iso_code']} ({$inr_currency['name']}). The order value of <b>" . Tools::displayPrice($amount, 4) . "</b> will be processed.</p><p>Currency conversion rates are provided by  openexchangerates.org</p>";
             $smarty->assign("curr_conversion_msg", $curr_conversion_msg);
         }
     } else {
         if ((int) $curr_currency['paypal_support'] === 1 && $cart->id_currency != 2) {
             //For all Paypal supported curencies except USD, we dont show PayU
             return;
         } else {
             if ($cart->id_currency != 2) {
                 // Currency not supported by Paypal and not USD, convert to USD and proceed
                 $amount = Tools::convertPrice($amount, $cart->id_currency, false);
                 $this_currency = CurrencyCore::getCurrency($cart->id_currency);
                 $curr_conversion_msg = "<p>Unfortunately we are unable to accept payments in <b>{$this_currency['name']}</b>.</p> <p>An equivalent order value of USD <b>" . Tools::displayPrice($amount, 2) . "</b> will be processed.</p>";
                 $smarty->assign("curr_conversion_msg", $curr_conversion_msg);
             }
         }
     }
     $amount = round($amount);
     //else
     //return;
     //convert to INR if the currency is not
     //if ($cart->id_currency != 4)
     //$amount = Tools::convertPrice($amount, 4, true);
     $customer = new Customer((int) $cart->id_customer);
     $action = 'https://test.payu.in/_payment.php';
     $txnid = $cart->id;
     $productInfo = 'Payu product information';
     $firstname = $customer->firstname;
     $Lastname = $customer->lastname;
     $deloveryAddress = new Address((int) $cart->id_address_invoice);
     $Zipcode = $deloveryAddress->postcode;
     $email = $customer->email;
     $phone = $deloveryAddress->phone;
     $deloveryAddress->country = Country::getNameById(1, $deloveryAddress->id_country);
     $deloveryAddress->state = State::getNameById($deloveryAddress->id_state);
     if ($mode == 'real') {
         $action = 'https://secure.payu.in/_payment.php';
     }
     $request = $key . '|' . $txnid . '|' . $amount . '|' . $productInfo . '|' . $firstname . '|' . $email . '|||||||||||' . $salt;
     $Hash = hash('sha512', $key . '|' . $txnid . '|' . $amount . '|' . $productInfo . '|' . $firstname . '|' . $email . '|||||||||||' . $salt);
     $baseUrl = Tools::getShopDomain(true, true) . __PS_BASE_URI__;
     if ($log == 1) {
         $query = "insert into ps_payu_order(id_order,payment_request) values({$orderId},'{$request}')";
         Db::getInstance()->Execute($query);
     }
     $surl = $baseUrl . 'modules/' . $this->name . '/success.php';
     $curl = $baseUrl . 'modules/' . $this->name . '/failure.php';
     $Furl = $baseUrl . 'modules/' . $this->name . '/failure.php';
     $Pg = 'CC';
     $payuInfo = array('action' => $action, 'key' => $key, 'txnid' => $txnid, 'amount' => $amount, 'productinfo' => $productInfo, 'firstname' => $firstname, 'Lastname' => $Lastname, 'Zipcode' => $Zipcode, 'email' => $email, 'phone' => $phone, 'surl' => $surl, 'Furl' => $Furl, 'curl' => $curl, 'Hash' => $Hash, 'Pg' => $Pg, 'deliveryAddress' => $deloveryAddress);
     $smarty->assign('Message', 'Please wait, you will be redirected to payu website');
     $smarty->assign($payuInfo);
     return $this->display(__FILE__, 'payu.tpl');
 }
开发者ID:priyankajsr19,项目名称:shalu,代码行数:77,代码来源:payu.php

示例6: getSummaryDetails

 /**
  * Return useful informations for cart
  *
  * @return array Cart details
  */
 function getSummaryDetails()
 {
     global $cookie;
     $delivery = new Address((int) $this->id_address_delivery);
     $invoice = new Address((int) $this->id_address_invoice);
     // New layout system with personalization fields
     $formattedAddresses['invoice'] = AddressFormat::getFormattedLayoutData($invoice);
     $formattedAddresses['delivery'] = AddressFormat::getFormattedLayoutData($delivery);
     $total_tax = $this->getOrderTotal() - $this->getOrderTotal(false);
     if ($total_tax < 0) {
         $total_tax = 0;
     }
     $total_free_ship = 0;
     if ($free_ship = Tools::convertPrice((double) Configuration::get('PS_SHIPPING_FREE_PRICE'), new Currency((int) $this->id_currency))) {
         $discounts = $this->getDiscounts();
         $total_free_ship = $free_ship - ($this->getOrderTotal(true, Cart::ONLY_PRODUCTS) + $this->getOrderTotal(true, Cart::ONLY_DISCOUNTS));
         foreach ($discounts as $discount) {
             if ($discount['id_discount_type'] == 3) {
                 $total_free_ship = 0;
                 break;
             }
         }
     }
     return array('delivery' => $delivery, 'delivery_state' => State::getNameById($delivery->id_state), 'invoice' => $invoice, 'invoice_state' => State::getNameById($invoice->id_state), 'formattedAddresses' => $formattedAddresses, 'carrier' => new Carrier((int) $this->id_carrier, $cookie->id_lang), 'products' => $this->getProducts(false), 'discounts' => $this->getDiscounts(false, true), 'is_virtual_cart' => (int) $this->isVirtualCart(), 'total_discounts' => $this->getOrderTotal(true, Cart::ONLY_DISCOUNTS), 'total_discounts_tax_exc' => $this->getOrderTotal(false, Cart::ONLY_DISCOUNTS), 'total_wrapping' => $this->getOrderTotal(true, Cart::ONLY_WRAPPING), 'total_wrapping_tax_exc' => $this->getOrderTotal(false, Cart::ONLY_WRAPPING), 'total_shipping' => $this->getOrderShippingCost(), 'total_shipping_tax_exc' => $this->getOrderShippingCost(NULL, false), 'total_products_wt' => $this->getOrderTotal(true, Cart::ONLY_PRODUCTS), 'total_products' => $this->getOrderTotal(false, Cart::ONLY_PRODUCTS), 'total_price' => $this->getOrderTotal(), 'total_tax' => $total_tax, 'total_price_without_tax' => $this->getOrderTotal(false), 'free_ship' => $total_free_ship);
 }
开发者ID:srikanthash09,项目名称:codetestdatld,代码行数:30,代码来源:Cart.php

示例7: initRecordData

 /**
  * Set the values of the fields that will be exported
  *
  * @param array $kiala_order content of the KialaOrder object
  * @return array|bool fields to be exported or false
  */
 public function initRecordData($kiala_order, $dspid)
 {
     if (!Validate::isLoadedObject($kiala_order)) {
         return false;
     }
     $order = new Order($kiala_order->id_order);
     $cart = new Cart($order->id_cart);
     $customer = new Customer($kiala_order->id_customer);
     $address = new Address($order->id_address_delivery);
     if (!Validate::isLoadedObject($order) || !Validate::isLoadedObject($customer) || !Validate::isLoadedObject($address)) {
         return false;
     }
     $products = $cart->getProducts();
     $width = 1;
     $height = 1;
     $depth = 1;
     foreach ($products as $product) {
         $width = $width < $product['width'] ? $product['width'] : $width;
         $height = $height < $product['height'] ? $product['height'] : $height;
         $depth = $depth < $product['depth'] ? $product['depth'] : $depth;
     }
     // volume in liters
     $volume = $width * $height * $depth / 1000;
     if ($volume < 1) {
         $volume = 1;
     }
     $prefix = Configuration::get('KIALA_NUMBER_PREFIX');
     $fields = array();
     $fields['partnerId']['value'] = $dspid;
     // Parcel information
     $fields['parcelBarcode']['value'] = '';
     $fields['parcelNumber']['value'] = $prefix . $kiala_order->id;
     $fields['orderNumber']['value'] = $prefix . $kiala_order->id;
     $fields['orderDate']['value'] = $this->formatDate($order->date_add);
     $fields['invoiceNumber']['value'] = $order->invoice_number ? $order->invoice_number : '';
     $fields['invoiceDate']['value'] = $this->formatDate($order->invoice_date);
     $fields['shipmentNumber']['value'] = '';
     // @todo Need to check currency = EUR
     if ($order->module == 'cashondelivery') {
         $cod_amount = $order->total_paid;
     } else {
         $cod_amount = '0';
     }
     $fields['CODAmount']['value'] = sprintf('%.2f', $cod_amount);
     $fields['CODCurrency']['value'] = 'EUR';
     $fields['commercialValue']['value'] = sprintf('%.2f', $kiala_order->commercialValue);
     $fields['commercialCurrency']['value'] = 'EUR';
     $fields['parcelWeight']['value'] = sprintf('%.3f', $order->getTotalWeight());
     $fields['parcelVolume']['value'] = sprintf('%.3f', $volume);
     $fields['parcelDescription']['value'] = $kiala_order->parcelDescription;
     // Point information
     $fields['kialaPoint']['value'] = $kiala_order->point_short_id;
     $fields['backupKialaPoint']['value'] = '';
     // Recipient information
     $fields['customerId']['value'] = $customer->id;
     $fields['customerName']['value'] = $customer->lastname;
     $fields['customerFirstName']['value'] = $customer->firstname;
     switch ($customer->id_gender) {
         case '1':
             $title = $this->kiala_instance->l('Mr.');
             break;
         case '2':
             $title = $this->kiala_instance->l('Ms.');
             break;
         default:
             $title = '';
     }
     $fields['customerTitle']['value'] = $title;
     $fields['customerExtraAddressLine']['value'] = $address->address2;
     $fields['customerStreet']['value'] = $address->address1;
     $fields['customerStreetNumber']['value'] = '';
     $fields['customerLocality']['value'] = State::getNameById($address->id_state);
     $fields['customerZip']['value'] = $address->postcode;
     $fields['customerCity']['value'] = $address->city;
     $fields['customerCountry']['value'] = Country::getIsoById($address->id_country);
     $fields['customerLanguage']['value'] = strtolower(Language::getIsoById($order->id_lang));
     $fields['positiveNotificationRequested']['value'] = 'Y';
     $fields['customerPhone1']['value'] = $address->phone;
     $fields['customerPhone2']['value'] = $address->phone_mobile;
     $fields['customerPhone3']['value'] = '';
     $fields['customerEmail1']['value'] = $customer->email;
     $fields['customerEmail2']['value'] = '';
     $fields['customerEmail3']['value'] = '';
     return $fields;
 }
开发者ID:ventsiwad,项目名称:presta_addons,代码行数:91,代码来源:ExportFormat.php

示例8: processPayment

 function processPayment($token)
 {
     include dirname(__FILE__) . '/lib/Twocheckout/TwocheckoutApi.php';
     $cart = $this->context->cart;
     $user = $this->context->customer;
     $delivery = new Address(intval($cart->id_address_delivery));
     $invoice = new Address(intval($cart->id_address_invoice));
     $customer = new Customer(intval($cart->id_customer));
     $currencies = Currency::getCurrencies();
     $authorized_currencies = array_flip(explode(',', $this->currencies));
     $currencies_used = array();
     foreach ($currencies as $key => $currency) {
         if (isset($authorized_currencies[$currency['id_currency']])) {
             $currencies_used[] = $currencies[$key];
         }
     }
     foreach ($currencies_used as $currency) {
         if ($currency['id_currency'] == $cart->id_currency) {
             $order_currency = $currency['iso_code'];
         }
     }
     try {
         $params = array("sellerId" => Configuration::get('TWOCHECKOUT_SID'), "merchantOrderId" => $cart->id, "token" => $token, "currency" => $order_currency, "total" => number_format($cart->getOrderTotal(true, 3), 2, '.', ''), "billingAddr" => array("name" => $invoice->firstname . ' ' . $invoice->lastname, "addrLine1" => $invoice->address1, "addrLine2" => $invoice->address2, "city" => $invoice->city, "state" => $invoice->country == "United States" || $invoice->country == "Canada" ? State::getNameById($invoice->id_state) : 'XX', "zipCode" => $invoice->postcode, "country" => $invoice->country, "email" => $customer->email, "phoneNumber" => $invoice->phone));
         if ($delivery) {
             $shippingAddr = array("name" => $delivery->firstname . ' ' . $delivery->lastname, "addrLine1" => $delivery->address1, "addrLine2" => $delivery->address2, "city" => $delivery->city, "state" => (Validate::isLoadedObject($delivery) and $delivery->id_state) ? new State(intval($delivery->id_state)) : 'XX', "zipCode" => $delivery->postcode, "country" => $delivery->country);
             array_merge($shippingAddr, $params);
         }
         if (Configuration::get('TWOCHECKOUT_SANDBOX')) {
             TwocheckoutApi::setCredentials(Configuration::get('TWOCHECKOUT_SID'), Configuration::get('TWOCHECKOUT_PRIVATE'), 'sandbox');
         } else {
             TwocheckoutApi::setCredentials(Configuration::get('TWOCHECKOUT_SID'), Configuration::get('TWOCHECKOUT_PRIVATE'));
         }
         $charge = Twocheckout_Charge::auth($params);
     } catch (Twocheckout_Error $e) {
         $message = 'Payment Authorization Failed';
         Tools::redirect('index.php?controller=order&step=3&twocheckouterror=' . $message);
     }
     if (isset($charge['response']['responseCode'])) {
         $order_status = (int) Configuration::get('TWOCHECKOUT_ORDER_STATUS');
         $message = $charge['response']['responseMsg'];
         $this->validateOrder((int) $this->context->cart->id, _PS_OS_PAYMENT_, $charge['response']['total'], $this->displayName, $message, array(), null, false, $this->context->customer->secure_key);
         Tools::redirect('index.php?controller=order-confirmation?key=' . $user->secure_key . '&id_cart=' . (int) $cart->id . '&id_module=' . (int) $this->module->id . '&id_order=' . (int) $this->module->currentOrder);
     } else {
         $message = 'Payment Authorization Failed';
         Tools::redirect('index.php?controller=order&step=3&twocheckouterror=' . $message);
     }
 }
开发者ID:stefanikolov,项目名称:prestashop-2checkout-api,代码行数:47,代码来源:twocheckout.php

示例9: getTaxRates

 /**
  * @param $module
  * @return array
  */
 protected static function getTaxRates($module)
 {
     $taxRates = array();
     $taxRuleGroups = TaxRulesGroup::getTaxRulesGroups(true);
     foreach ($taxRuleGroups as $taxRuleGroup) {
         if (version_compare(_PS_VERSION_, '1.5.0.1', '<')) {
             $taxRules = TaxRule::getTaxRulesByGroupId($taxRuleGroup['id_tax_rules_group']);
         } else {
             $taxRules = TaxRule::getTaxRulesByGroupId($module->context->language->id, $taxRuleGroup['id_tax_rules_group']);
         }
         // $idCountry is only relevant for Prestashop versions <1.5.0.1
         foreach ($taxRules as $idCountry => $taxRuleItem) {
             $resultTaxRate = array();
             $resultTaxRate['zipcode_type'] = 'all';
             if (version_compare(_PS_VERSION_, '1.5.0.1', '>=')) {
                 $taxRuleItemTmp = new TaxRule($taxRuleItem['id_tax_rule']);
                 $idCountry = $taxRuleItemTmp->id_country;
                 $idState = $taxRuleItemTmp->id_state;
                 $idTax = $taxRuleItemTmp->id_tax;
                 if (!empty($taxRuleItemTmp->zipcode_from) && !empty($taxRuleItemTmp->zipcode_to)) {
                     $resultTaxRate['zipcode_type'] = 'range';
                     $resultTaxRate['zipcode_range_from'] = $taxRuleItemTmp->zipcode_from ? $taxRuleItemTmp->zipcode_from : null;
                     $resultTaxRate['zipcode_range_to'] = $taxRuleItemTmp->zipcode_to ? $taxRuleItemTmp->zipcode_to : null;
                 }
             } else {
                 $idTax = self::getTaxIdFromTaxRule($taxRuleItem);
                 $idState = key($taxRuleItem);
             }
             /** @var TaxCore $taxItem */
             $taxItem = new Tax($idTax, $module->context->language->id);
             $country = Country::getIsoById($idCountry);
             if (version_compare(_PS_VERSION_, '1.5.0.1', '<')) {
                 $state = State::getNameById($idState);
             } else {
                 $stateModel = new State($idState);
                 $state = $stateModel->iso_code;
             }
             $resultTaxRate['key'] = self::getTaxRateKey($taxItem, $country, $state);
             //Fix for 1.4.x.x the taxes were exported multiple
             if (version_compare(_PS_VERSION_, '1.5.0', '<') && self::arrayValueExists('key', $resultTaxRate['key'], $taxRates)) {
                 continue;
             }
             if (!is_string($country)) {
                 $country = '';
             }
             $resultTaxRate['display_name'] = $taxItem->name;
             $resultTaxRate['tax_percent'] = $taxItem->rate;
             $resultTaxRate['country'] = $country;
             $resultTaxRate['state'] = !empty($state) ? $country . '-' . $state : null;
             if ($taxItem->active && Configuration::get('PS_TAX') == 1) {
                 $taxRates[] = $resultTaxRate;
             }
         }
     }
     return $taxRates;
 }
开发者ID:pankajshoffex,项目名称:shoffex_prestashop,代码行数:60,代码来源:Settings.php

示例10: hookDisplayAdminOrder

 public function hookDisplayAdminOrder($params)
 {
     if (!$this->hasShiptomyidOption($params['id_order'])) {
         return;
     }
     $shipto_order = ShiptomyidOrder::getByIdOrder($params['id_order']);
     if (!Validate::isLoadedObject($shipto_order)) {
         return false;
     }
     $order = new Order($shipto_order->id_order);
     if ($order->current_state == self::$os_ps_canceled || $order->current_state == self::$os_cancel) {
         return false;
     }
     $shipto_order->country_name = Country::getNameById($this->context->language->id, $shipto_order->id_country);
     $shipto_order->state_name = State::getNameById($shipto_order->id_state);
     $this->context->smarty->assign(array('shipto_order' => $shipto_order));
     return $this->display($this->_path, 'admin-order.tpl');
 }
开发者ID:ship2myidpresta,项目名称:shiptomyid-1,代码行数:18,代码来源:shiptomyid.php

示例11: findAllSimilarAddressesForAddress

 /**
  * it is used to create a list of relevant addresses for given address.
  * used in admin panel to validate the postcode
  *
  * @param array $address The content will be the edit form for address from admin
  *                       $address contain next keys
  *                       MANDATORY
  *                       country
  *                       city
  *
  * OPTIONAL
  *      region
  *      address
  *      street
  * @return bool|string
  */
 public function findAllSimilarAddressesForAddress($address)
 {
     $address['region'] = '';
     $country_name = '';
     if (!empty($address['country_id'])) {
         $country_object = new Country();
         $country_name = $country_object->getNameById($address['lang_id'], $address['country_id']);
         $address['country'] = $country_name;
     }
     if ($this->isEnabledAutocompleteForPostcode($country_name)) {
         if ($address['region_id']) {
             $region_name = State::getNameById($address['region_id']);
             $address['region'] = $region_name;
         }
         if (empty($address['region'])) {
             $regions = DpdGroupDpdPostcodeMysql::identifyRegionByCity($address['city']);
             if ($regions && count($regions) == 1) {
                 $address['region'] = array_pop($regions);
             }
         }
         $found_addresses = self::getInstance()->searchSimilarAddresses($address);
         return $found_addresses;
     }
     return false;
 }
开发者ID:remixaz,项目名称:dpdgroup,代码行数:41,代码来源:PostcodeSearch.php

示例12: _getPaymentData

 /**
  * @param float $amount
  * @param string $method
  * @param string|null $issuer
  * @param int $cart_id
  * @return array
  */
 protected function _getPaymentData($amount, $method, $issuer, $cart_id, $secure_key)
 {
     $payment_data = array("amount" => $amount, "method" => $method, "issuer" => $issuer, "description" => str_replace('%', $cart_id, $this->module->getConfigValue('MOLLIE_DESCRIPTION')), "redirectUrl" => $this->context->link->getModuleLink('mollie', 'return', array('cart_id' => $cart_id, 'utm_nooverride' => 1)), "webhookUrl" => $this->context->link->getModuleLink('mollie', 'webhook'), "metadata" => array("cart_id" => $cart_id, "secure_key" => $secure_key));
     // Send webshop locale
     if ($this->module->getConfigValue('MOLLIE_PAYMENTSCREEN_LOCALE') === Mollie::PAYMENTSCREEN_LOCALE_SEND_WEBSITE_LOCALE) {
         $locale = $this->_getWebshopLocale();
         if (preg_match('/^[a-z]{2}(?:[\\-_][A-Z]{2})?$/iu', $locale)) {
             $payment_data['locale'] = $locale;
         }
     }
     if (isset($this->context, $this->context->cart)) {
         if (isset($this->context->cart->id_address_invoice)) {
             $billing = new Address(intval($this->context->cart->id_address_invoice));
             $payment_data['billingCity'] = $billing->city;
             $payment_data['billingRegion'] = State::getNameById($billing->id_state);
             $payment_data['billingPostal'] = $billing->postcode;
             $payment_data['billingCountry'] = Country::getIsoById($billing->id_country);
         }
         if (isset($this->context->cart->id_address_delivery)) {
             $shipping = new Address(intval($this->context->cart->id_address_delivery));
             $payment_data['shippingCity'] = $shipping->city;
             $payment_data['shippingRegion'] = State::getNameById($shipping->id_state);
             $payment_data['shippingPostal'] = $shipping->postcode;
             $payment_data['shippingCountry'] = Country::getIsoById($shipping->id_country);
         }
     }
     return $payment_data;
 }
开发者ID:javolero,项目名称:Prestashop,代码行数:35,代码来源:payment.php

示例13: execPayment

 function execPayment($cart)
 {
     $delivery = new Address(intval($cart->id_address_delivery));
     $invoice = new Address(intval($cart->id_address_invoice));
     $customer = new Customer(intval($cart->id_customer));
     global $cookie, $smarty;
     //Verify currencies and display payment form
     $cart_details = $cart->getSummaryDetails(null, true);
     $currencies = Currency::getCurrencies();
     $authorized_currencies = array_flip(explode(',', $this->currencies));
     $currencies_used = array();
     foreach ($currencies as $key => $currency) {
         if (isset($authorized_currencies[$currency['id_currency']])) {
             $currencies_used[] = $currencies[$key];
         }
     }
     $smarty->assign('currencies_used', $currencies_used);
     $order_currency = '';
     foreach ($currencies_used as $key => $currency) {
         if ($currency['id_currency'] == $cart->id_currency) {
             $order_currency = $currency['iso_code'];
         }
     }
     $products = $cart->getProducts();
     foreach ($products as $key => $product) {
         $products[$key]['name'] = str_replace('"', '\'', $product['name']);
         $products[$key]['name'] = htmlentities(utf8_decode($product['name']));
     }
     $discounts = $cart_details['discounts'];
     $carrier = $cart_details['carrier'];
     if (_PS_VERSION_ < '1.5') {
         $shipping_cost = $cart_details['total_shipping_tax_exc'];
     } else {
         $shipping_cost = $this->context->cart->getTotalShippingCost();
     }
     $CheckoutUrl = 'https://www.2checkout.com/checkout/purchase';
     $sid = Configuration::get('CHECKOUT_SID');
     $display = Configuration::get('CHECKOUT_DISPLAY');
     $amount = number_format($cart->getOrderTotal(true, 3), 2, '.', '');
     $cart_order_id = $cart->id;
     $email = $customer->email;
     $secure_key = $customer->secure_key;
     $demo = "N";
     // Change to "Y" for demo mode
     $outside_state = "XX";
     // This will pre-select Outside USA and Canada, if state does not exist
     // Invoice Parameters
     $card_holder_name = $invoice->firstname . ' ' . $invoice->lastname;
     $street_address = $invoice->address1;
     $street_address2 = $invoice->address2;
     $phone = $invoice->phone;
     $city = $invoice->city;
     $state = (Validate::isLoadedObject($invoice) and $invoice->id_state) ? new State(intval($invoice->id_state)) : false;
     $zip = $invoice->postcode;
     $country = $invoice->country;
     // Shipping Parameters
     $ship_name = $delivery->firstname . ' ' . $invoice->lastname;
     $ship_street_address = $delivery->address1;
     $ship_street_address2 = $delivery->address2;
     $ship_city = $delivery->city;
     $ship_state = (Validate::isLoadedObject($delivery) and $delivery->id_state) ? new State(intval($delivery->id_state)) : false;
     $ship_zip = $delivery->postcode;
     $ship_country = $delivery->country;
     $check_total = $this->checkTotal($cart);
     if (Configuration::get('CHECKOUT_CURRENCY') > 0) {
         $currency_from = Currency::getCurrency($cart->id_currency);
         $currency_to = Currency::getCurrency(Configuration::get('CHECKOUT_CURRENCY'));
         $amount = Tools::ps_round($amount / $currency_from['conversion_rate'], 2);
         $total = Tools::ps_round($amount *= $currency_to['conversion_rate'], 2);
         $order_currency = $currency_to['iso_code'];
         $override_currency = $currency_to;
     } else {
         $total = number_format($cart->getOrderTotal(true, 3), 2, '.', '');
         $override_currency = 0;
     }
     $smarty->assign(array('CheckoutUrl' => $CheckoutUrl, 'check_total' => $check_total, 'sid' => $sid, 'display' => $display, 'total' => $total, 'cart_order_id' => $cart_order_id, 'email' => $email, 'outside_state' => $outside_state, 'secure_key' => $secure_key, 'card_holder_name' => $card_holder_name, 'street_address' => $street_address, 'street_address2' => $street_address2, 'phone' => $phone, 'city' => $city, 'state' => $state, 'zip' => $zip, 'country' => $country, 'ship_name' => $ship_name, 'ship_street_address' => $ship_street_address, 'ship_street_address2' => $ship_street_address2, 'ship_city' => $ship_city, 'ship_state' => $ship_state, 'ship_zip' => $ship_zip, 'ship_country' => $ship_country, 'products' => $products, 'currency_code' => $order_currency, 'override_currency' => $override_currency, 'TotalAmount' => $total, 'this_path' => $this->_path, 'this_path_ssl' => Configuration::get('PS_FO_PROTOCOL') . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . "modules/{$this->name}/"));
     //shipping lineitem
     if ($shipping_cost > 0) {
         $smarty->assign('shipping_cost', $shipping_cost);
     }
     //tax lineitem
     if ($cart_details['total_tax'] > 0) {
         $smarty->assign('tax', $cart_details['total_tax']);
     }
     //coupon lineitem
     if ($cart_details['total_discounts'] > 0) {
         $smarty->assign('discount', $cart_details['total_discounts_tax_exc']);
     }
     $cart = new Cart($cookie->id_cart);
     $address = new Address($cart->id_address_delivery, intval($cookie->id_lang));
     $state = State::getNameById($address->id_state);
     $state = $state ? '(' . $state . ')' : '';
     $str_address = ($address->company ? $address->company . '<br>' : '') . $address->firstname . ' ' . $address->lastname . '<br>' . $address->address1 . '<br>' . ($address->address2 ? $address->address2 . '<br>' : '') . $address->postcode . ' ' . $address->city . '<br>' . $address->country . $state;
     $smarty->assign('address', $str_address);
     $carrier = Carrier::getCarriers(intval($cookie->id_lang));
     if ($carrier) {
         foreach ($carrier as $c) {
             if ($cart->id_carrier == $c['id_carrier']) {
                 $smarty->assign('carrier', $c['name']);
                 break;
//.........这里部分代码省略.........
开发者ID:dlorenzo92,项目名称:PrestaShop-2Checkout,代码行数:101,代码来源:checkout.php

示例14: getSummaryDetails

 /**
  * Return useful informations for cart
  *
  * @return array Cart details
  */
 function getSummaryDetails()
 {
     global $cookie;
     $delivery = new Address(intval($this->id_address_delivery));
     $invoice = new Address(intval($this->id_address_invoice));
     return array('delivery' => $delivery, 'delivery_state' => State::getNameById($delivery->id_state), 'invoice' => $invoice, 'invoice_state' => State::getNameById($invoice->id_state), 'carrier' => new Carrier(intval($this->id_carrier), $cookie->id_lang), 'products' => $this->getProducts(false), 'discounts' => $this->getDiscounts(), 'total_discounts' => $this->getOrderTotal(true, 2), 'total_discounts_tax_exc' => $this->getOrderTotal(false, 2), 'total_wrapping' => $this->getOrderTotal(true, 6), 'total_wrapping_tax_exc' => $this->getOrderTotal(false, 6), 'total_shipping' => $this->getOrderShippingCost(), 'total_shipping_tax_exc' => $this->getOrderShippingCost(NULL, false), 'total_products_wt' => $this->getOrderTotal(true, 1), 'total_products' => $this->getOrderTotal(false, 1), 'total_price' => $this->getOrderTotal(), 'total_tax' => $this->getOrderTotal() - $this->getOrderTotal(false), 'total_price_without_tax' => $this->getOrderTotal(false));
 }
开发者ID:vincent,项目名称:theinvertebrates,代码行数:12,代码来源:Cart.php

示例15: execPayment

 function execPayment($cart)
 {
     $delivery = new Address(intval($cart->id_address_delivery));
     $invoice = new Address(intval($cart->id_address_invoice));
     $customer = new Customer(intval($cart->id_customer));
     global $cookie, $smarty;
     //Verify currencies and display payment form
     $cart_details = $cart->getSummaryDetails(null, true);
     $currencies = Currency::getCurrencies();
     $authorized_currencies = array_flip(explode(',', $this->currencies));
     $currencies_used = array();
     foreach ($currencies as $key => $currency) {
         if (isset($authorized_currencies[$currency['id_currency']])) {
             $currencies_used[] = $currencies[$key];
         }
     }
     $order_currency = '';
     foreach ($currencies_used as $key => $currency) {
         if ($currency['id_currency'] == $cart->id_currency) {
             $order_currency = $currency['iso_code'];
         }
     }
     $products = $cart->getProducts();
     foreach ($products as $key => $product) {
         $products[$key]['name'] = str_replace('"', '\'', $product['name']);
         $products[$key]['name'] = htmlentities(utf8_decode($product['name']));
     }
     $discounts = $cart_details['discounts'];
     $carrier = $cart_details['carrier'];
     if (_PS_VERSION_ < '1.5') {
         $shipping_cost = $cart_details['total_shipping_tax_exc'];
     } else {
         $shipping_cost = $this->context->cart->getTotalShippingCost();
     }
     $CheckoutUrl = 'https://www.2checkout.com/checkout/purchase';
     $sid = Configuration::get('TWOCHECKOUTPP_SID');
     $amount = number_format($cart->getOrderTotal(true, 3), 2, '.', '');
     $cart_order_id = $cart->id;
     $email = $customer->email;
     $secure_key = $customer->secure_key;
     $demo = "N";
     // Change to "Y" for demo mode
     $outside_state = "XX";
     // This will pre-select Outside USA and Canada, if state does not exist
     // Invoice Parameters
     $card_holder_name = $invoice->firstname . ' ' . $invoice->lastname;
     $street_address = $invoice->address1;
     $street_address2 = $invoice->address2;
     $phone = $invoice->phone;
     $city = $invoice->city;
     $state = (Validate::isLoadedObject($invoice) and $invoice->id_state) ? new State(intval($invoice->id_state)) : false;
     $zip = $invoice->postcode;
     $country = $invoice->country;
     // Shipping Parameters
     $ship_name = $delivery->firstname . ' ' . $invoice->lastname;
     $ship_street_address = $delivery->address1;
     $ship_street_address2 = $delivery->address2;
     $ship_city = $delivery->city;
     $ship_state = (Validate::isLoadedObject($delivery) and $delivery->id_state) ? new State(intval($delivery->id_state)) : false;
     $ship_zip = $delivery->postcode;
     $ship_country = $delivery->country;
     $check_total = $this->checkTotal($cart);
     if (Configuration::get('TWOCHECKOUTPP_CURRENCY') > 0) {
         $currency_from = Currency::getCurrency($cart->id_currency);
         $currency_to = Currency::getCurrency(Configuration::get('TWOCHECKOUTPP_CURRENCY'));
         $amount = Tools::ps_round($amount / $currency_from['conversion_rate'], 2);
         $total = Tools::ps_round($amount *= $currency_to['conversion_rate'], 2);
         $order_currency = $currency_to['iso_code'];
         $override_currency = $currency_to;
     } else {
         $total = number_format($cart->getOrderTotal(true, 3), 2, '.', '');
         $override_currency = 0;
     }
     $cart = new Cart($cookie->id_cart);
     $address = new Address($cart->id_address_delivery, intval($cookie->id_lang));
     $state = State::getNameById($address->id_state);
     $state = $state ? '(' . $state . ')' : '';
     $str_address = ($address->company ? $address->company . '<br>' : '') . $address->firstname . ' ' . $address->lastname . '<br>' . $address->address1 . '<br>' . ($address->address2 ? $address->address2 . '<br>' : '') . $address->postcode . ' ' . $address->city . '<br>' . $address->country . $state;
     $carrier = Carrier::getCarriers(intval($cookie->id_lang));
     if ($carrier) {
         foreach ($carrier as $c) {
             if ($cart->id_carrier == $c['id_carrier']) {
                 $carrier_name = $c['name'];
                 break;
             }
         }
     }
     $params = array();
     $params['sid'] = $sid;
     $params['paypal_direct'] = 'Y';
     $params['currency_code'] = $order_currency;
     $params['return_url'] = $this->context->link->getPageLink('order', true, NULL, "step=3");
     $params['merchant_order_id'] = $cart_order_id;
     $params['email'] = $email;
     $params['phone'] = $phone;
     $params['card_holder_name'] = $card_holder_name;
     $params['street_address'] = $street_address;
     $params['street_address2'] = $street_address2;
     $params['city'] = $city;
     $params['state'] = $state;
//.........这里部分代码省略.........
开发者ID:stefanikolov,项目名称:prestashop-2checkout-api,代码行数:101,代码来源:twocheckoutpp.php


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