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


PHP State::getIdByIso方法代码示例

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


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

示例1: postProcess

 public function postProcess()
 {
     if (Tools::isSubmit($this->table . 'Orderby') || Tools::isSubmit($this->table . 'Orderway')) {
         $this->filter = true;
     }
     if (!isset($this->table)) {
         return false;
     }
     if (!Tools::getValue('id_' . $this->table)) {
         if (Validate::isStateIsoCode(Tools::getValue('iso_code')) && State::getIdByIso(Tools::getValue('iso_code'), Tools::getValue('id_country'))) {
             $this->errors[] = Tools::displayError('This ISO code already exists. You cannot create two states with the same ISO code.');
         }
     } else {
         if (Validate::isStateIsoCode(Tools::getValue('iso_code'))) {
             $id_state = State::getIdByIso(Tools::getValue('iso_code'), Tools::getValue('id_country'));
             if ($id_state && $id_state != Tools::getValue('id_' . $this->table)) {
                 $this->errors[] = Tools::displayError('This ISO code already exists. You cannot create two states with the same ISO code.');
             }
         }
     }
     /* Delete object */
     if (isset($_GET['delete' . $this->table])) {
         // set token
         $token = Tools::getValue('token') ? Tools::getValue('token') : $this->token;
         if ($this->tabAccess['delete'] === '1') {
             if (Validate::isLoadedObject($object = $this->loadObject()) && isset($this->fieldImageSettings)) {
                 if (!$object->isUsed()) {
                     // check if request at least one object with noZeroObject
                     if (isset($object->noZeroObject) && count($taxes = call_user_func(array($this->className, $object->noZeroObject))) <= 1) {
                         $this->errors[] = Tools::displayError('You need at least one object.') . ' <b>' . $this->table . '</b><br />' . Tools::displayError('You cannot delete all of the items.');
                     } else {
                         if ($this->deleted) {
                             $object->deleted = 1;
                             if ($object->update()) {
                                 Tools::redirectAdmin(self::$currentIndex . '&conf=1&token=' . $token);
                             }
                         } else {
                             if ($object->delete()) {
                                 Tools::redirectAdmin(self::$currentIndex . '&conf=1&token=' . $token);
                             }
                         }
                         $this->errors[] = Tools::displayError('An error occurred during deletion.');
                     }
                 } else {
                     $this->errors[] = Tools::displayError('This state was used in at least one address. It cannot be removed.');
                 }
             } else {
                 $this->errors[] = Tools::displayError('An error occurred while deleting the object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
             }
         } else {
             $this->errors[] = Tools::displayError('You do not have permission to delete this.');
         }
     } else {
         parent::postProcess();
     }
 }
开发者ID:FAVHYAN,项目名称:a3workout,代码行数:56,代码来源:AdminStatesController.php

示例2: postProcess

 public function postProcess()
 {
     if (Tools::isSubmit($this->table . 'Orderby') || Tools::isSubmit($this->table . 'Orderway')) {
         $this->filter = true;
     }
     // Idiot-proof controls
     if (!Tools::getValue('id_' . $this->table)) {
         if (Validate::isStateIsoCode(Tools::getValue('iso_code')) && State::getIdByIso(Tools::getValue('iso_code'), Tools::getValue('id_country'))) {
             $this->errors[] = Tools::displayError('This ISO code already exists. You cannot create two states with the same ISO code.');
         }
     } elseif (Validate::isStateIsoCode(Tools::getValue('iso_code'))) {
         $id_state = State::getIdByIso(Tools::getValue('iso_code'), Tools::getValue('id_country'));
         if ($id_state && $id_state != Tools::getValue('id_' . $this->table)) {
             $this->errors[] = Tools::displayError('This ISO code already exists. You cannot create two states with the same ISO code.');
         }
     }
     /* Delete state */
     if (Tools::isSubmit('delete' . $this->table)) {
         if ($this->tabAccess['delete'] === '1') {
             if (Validate::isLoadedObject($object = $this->loadObject())) {
                 /** @var State $object */
                 if (!$object->isUsed()) {
                     if ($object->delete()) {
                         Tools::redirectAdmin(self::$currentIndex . '&conf=1&token=' . (Tools::getValue('token') ? Tools::getValue('token') : $this->token));
                     }
                     $this->errors[] = Tools::displayError('An error occurred during deletion.');
                 } else {
                     $this->errors[] = Tools::displayError('This state was used in at least one address. It cannot be removed.');
                 }
             } else {
                 $this->errors[] = Tools::displayError('An error occurred while deleting the object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
             }
         } else {
             $this->errors[] = Tools::displayError('You do not have permission to delete this.');
         }
     }
     if (!count($this->errors)) {
         parent::postProcess();
     }
 }
开发者ID:prestanesia,项目名称:PrestaShop,代码行数:40,代码来源:AdminStatesController.php

示例3: _expressCheckout

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

示例4: createAddress

 /**
  * Create or Updates Prestashop address
  * @return Address Address object
  */
 protected function createAddress($addressInformations, $address = null)
 {
     $country = $this->getCountryByCode($addressInformations->country->alpha2Code);
     if (!$country->active) {
         $this->addError(sprintf($this->module->l('This country is not active : %s'), $addressInformations->country->alpha2Code), PowaTagErrorType::$MERCHANT_WRONG_COUNTRY);
         return false;
     }
     if (!isset($addressInformations->friendlyName)) {
         $friendlyName = $this->module->l('My address');
     } else {
         $friendlyName = $addressInformations->friendlyName;
     }
     if (PowaTagAPI::apiLog()) {
         PowaTagLogs::initAPILog('Create address', PowaTagLogs::IN_PROGRESS, $addressInformations->lastName . ' ' . $addressInformations->firstName . ' : ' . $friendlyName);
     }
     $address = $address != null ? $address : Address::initialize();
     $address->id_customer = (int) $this->customer->id;
     $address->id_country = (int) $country->id;
     $address->alias = $friendlyName;
     $address->lastname = $addressInformations->lastName;
     $address->firstname = $addressInformations->firstName;
     $address->address1 = $addressInformations->line1;
     $address->address2 = $addressInformations->line2;
     $address->postcode = $addressInformations->postCode;
     $address->city = $addressInformations->city;
     $address->phone = isset($addressInformations->phone) ? $addressInformations->phone : '0000000000';
     $address->id_state = isset($addressInformations->state) ? (int) State::getIdByIso($addressInformations->state, (int) $country->id) : 0;
     if (!$address->save()) {
         $this->addError($this->module->l('Impossible to save address'), PowaTagErrorType::$INTERNAL_ERROR);
         if (PowaTagAPI::apiLog()) {
             PowaTagLogs::initAPILog('Create address', PowaTagLogs::ERROR, $this->error['message']);
         }
         return false;
     }
     if (PowaTagAPI::apiLog()) {
         PowaTagLogs::initAPILog('Create address', PowaTagLogs::SUCCESS, 'Address ID : ' . $address->id);
     }
     return $address;
 }
开发者ID:powa,项目名称:prestashop-extension,代码行数:43,代码来源:PowaTagAbstract.php

示例5: setCustomerAddress

/**
 * Set customer address (when not logged in)
 * Used to create user address with PayPal account information
 */
function setCustomerAddress($ppec, $customer, $id = null)
{
    $address = new Address($id);
    $address->id_country = Country::getByIso($ppec->result['COUNTRYCODE']);
    $address->alias = 'Paypal_Address';
    $address->lastname = $customer->lastname;
    $address->firstname = $customer->firstname;
    $address->address1 = $ppec->result['PAYMENTREQUEST_0_SHIPTOSTREET'];
    if (isset($ppec->result['PAYMENTREQUEST_0_SHIPTOSTREET2'])) {
        $address->address2 = $ppec->result['PAYMENTREQUEST_0_SHIPTOSTREET2'];
    }
    $address->city = $ppec->result['PAYMENTREQUEST_0_SHIPTOCITY'];
    $address->id_state = (int) State::getIdByIso($ppec->result['SHIPTOSTATE'], $address->id_country);
    $address->postcode = $ppec->result['SHIPTOZIP'];
    $address->id_customer = $customer->id;
    return $address;
}
开发者ID:ventsiwad,项目名称:presta_addons,代码行数:21,代码来源:payment.php

示例6: createStates

 private static function createStates()
 {
     $ps_state_iso_code_max_length = 7;
     if (version_compare(_PS_VERSION_, '1.5', '<')) {
         $ps_state_iso_code_max_length = 4;
     }
     foreach (SeurLib::$baleares_states as $iso_code => $state_name) {
         if (Tools::strlen($iso_code) > $ps_state_iso_code_max_length) {
             $tmpArray = explode('-', $iso_code);
             $iso_code = $tmpArray[0];
             if (count($tmpArray) > 0) {
                 $iso_code = 'E' . $tmpArray[1];
             }
         }
         $exists_id = State::getIdByIso($iso_code);
         if (isset($exists_id) && !empty($exists_id)) {
             $state = new State($exists_id);
             $state->active = true;
             $state->id_zone = self::$baleares->id;
             if (!$state->update()) {
                 return false;
             }
         } else {
             $state = new State();
             $state->name = $state_name;
             $state->id_country = self::$spain->id;
             $state->id_zone = self::$baleares->id;
             $state->iso_code = $iso_code;
             $state->active = true;
             if (!$state->save()) {
                 return false;
             }
         }
     }
     foreach (SeurLib::$canarias_states as $iso_code => $state_name) {
         if (Tools::strlen($iso_code) > $ps_state_iso_code_max_length) {
             $tmpArray = explode('-', $iso_code);
             $iso_code = $tmpArray[0];
             if (count($tmpArray) > 0) {
                 $iso_code = 'E' . $tmpArray[1];
             }
         }
         $exists_id = State::getIdByIso($iso_code);
         if (isset($exists_id) && !empty($exists_id)) {
             $state = new State($exists_id);
             $state->active = true;
             $state->id_zone = self::$canarias->id;
             if (!$state->update()) {
                 return false;
             }
         } else {
             $state = new State();
             $state->name = $state_name;
             $state->id_country = self::$spain->id;
             $state->id_zone = self::$canarias->id;
             $state->iso_code = $iso_code;
             $state->active = true;
             if (!$state->save()) {
                 return false;
             }
         }
     }
     foreach (SeurLib::$ceuta_melilla_states as $iso_code => $state_name) {
         if (Tools::strlen($iso_code) > $ps_state_iso_code_max_length) {
             $tmpArray = explode('-', $iso_code);
             $iso_code = $tmpArray[0];
             if (count($tmpArray) > 0) {
                 $iso_code = 'E' . $tmpArray[1];
             }
         }
         $exists_id = State::getIdByIso($iso_code);
         if (isset($exists_id) && !empty($exists_id)) {
             $state = new State($exists_id);
             $state->id_zone = self::$ceuta_melilla->id;
             $state->active = true;
             if (!$state->update()) {
                 return false;
             }
         } else {
             $state = new State();
             $state->name = $state_name;
             $state->id_country = self::$spain->id;
             $state->id_zone = self::$ceuta_melilla->id;
             $state->iso_code = $iso_code;
             $state->active = true;
             if (!$state->save()) {
                 return false;
             }
         }
     }
     foreach (SeurLib::$spain_states as $iso_code => $state_name) {
         if (Tools::strlen($iso_code) > $ps_state_iso_code_max_length) {
             $tmpArray = explode('-', $iso_code);
             $iso_code = $tmpArray[0];
             if (count($tmpArray) > 0) {
                 $iso_code = 'E' . $tmpArray[1];
             }
         }
         $exists_id = State::getIdByIso($iso_code);
         if (isset($exists_id) && !empty($exists_id)) {
//.........这里部分代码省略.........
开发者ID:tomideru,项目名称:PrestaShop-modules,代码行数:101,代码来源:Range.php

示例7: getContent

    public function getContent()
    {
        $buffer = '';
        if (Tools::isSubmit('SubmitAvalaraTaxSettings')) {
            Configuration::updateValue('AVALARATAX_ACCOUNT_NUMBER', Tools::getValue('avalaratax_account_number'));
            Configuration::updateValue('AVALARATAX_LICENSE_KEY', Tools::getValue('avalaratax_license_key'));
            Configuration::updateValue('AVALARATAX_URL', Tools::getValue('avalaratax_url'));
            Configuration::updateValue('AVALARATAX_COMPANY_CODE', Tools::getValue('avalaratax_company_code'));
            $buffer .= $this->_displayConfirmation();
        } elseif (Tools::isSubmit('SubmitAvalaraTaxOptions')) {
            Configuration::updateValue('AVALARATAX_ADDRESS_VALIDATION', Tools::getValue('avalaratax_address_validation'));
            Configuration::updateValue('AVALARATAX_TAX_CALCULATION', Tools::getValue('avalaratax_tax_calculation'));
            Configuration::updateValue('AVALARATAX_TIMEOUT', (int) Tools::getValue('avalaratax_timeout'));
            Configuration::updateValue('AVALARATAX_ADDRESS_NORMALIZATION', Tools::getValue('avalaratax_address_normalization'));
            Configuration::updateValue('AVALARATAX_TAX_OUTSIDE', Tools::getValue('avalaratax_tax_outside'));
            Configuration::updateValue('AVALARA_CACHE_MAX_LIMIT', Tools::getValue('avalara_cache_max_limit') < 1 ? 1 : Tools::getValue('avalara_cache_max_limit') > 23 ? 23 : Tools::getValue('avalara_cache_max_limit'));
            $buffer .= $this->_displayConfirmation();
        } elseif (Tools::isSubmit('SubmitAvalaraTestConnection')) {
            $connectionTestResult = $this->_testConnection();
        } elseif (Tools::isSubmit('SubmitAvalaraAddressOptions')) {
            /* Validate address*/
            $address = new Address();
            $address->address1 = Tools::getValue('avalaratax_address_line1');
            $address->address2 = Tools::getValue('avalaratax_address_line2');
            $address->city = Tools::getValue('avalaratax_city');
            $address->id_state = State::getIdByIso(Tools::getValue('avalaratax_state'));
            $address->id_country = Tools::getValue('avalaratax_country');
            $address->postcode = Tools::getValue('avalaratax_zip_code');
            $normalizedAddress = $this->validateAddress($address);
            if (isset($normalizedAddress['ResultCode']) && $normalizedAddress['ResultCode'] == 'Success') {
                $buffer .= $this->_displayConfirmation($this->l('The address you submitted has been validated.'));
                Configuration::updateValue('AVALARATAX_ADDRESS_LINE1', $normalizedAddress['Normalized']['Line1']);
                Configuration::updateValue('AVALARATAX_ADDRESS_LINE2', $normalizedAddress['Normalized']['Line2']);
                Configuration::updateValue('AVALARATAX_CITY', $normalizedAddress['Normalized']['City']);
                Configuration::updateValue('AVALARATAX_STATE', $normalizedAddress['Normalized']['Region']);
                Configuration::updateValue('AVALARATAX_COUNTRY', $normalizedAddress['Normalized']['Country']);
                Configuration::updateValue('AVALARATAX_ZIP_CODE', $normalizedAddress['Normalized']['PostalCode']);
            } else {
                $message = $this->l('The following error was generated while validating your address:');
                if (isset($normalizedAddress['Exception']['FaultString'])) {
                    $message .= '<br /> - ' . Tools::safeOutput($normalizedAddress['Exception']['FaultString']);
                }
                if (isset($normalizedAddress['Messages']['Summary'])) {
                    foreach ($normalizedAddress['Messages']['Summary'] as $summary) {
                        $message .= '<br /> - ' . Tools::safeOutput($summary);
                    }
                }
                $buffer .= $this->_displayConfirmation($message, 'error');
                Configuration::updateValue('AVALARATAX_ADDRESS_LINE1', Tools::getValue('avalaratax_address_line1'));
                Configuration::updateValue('AVALARATAX_ADDRESS_LINE2', Tools::getValue('avalaratax_address_line2'));
                Configuration::updateValue('AVALARATAX_CITY', Tools::getValue('avalaratax_city'));
                Configuration::updateValue('AVALARATAX_STATE', Tools::getValue('avalaratax_state'));
                Configuration::updateValue('AVALARATAX_ZIP_CODE', Tools::getValue('avalaratax_zip_code'));
            }
        } elseif (Tools::isSubmit('SubmitAvalaraTaxClearCache')) {
            Db::getInstance()->Execute('TRUNCATE TABLE `' . _DB_PREFIX_ . 'avalara_product_cache`');
            Db::getInstance()->Execute('TRUNCATE TABLE `' . _DB_PREFIX_ . 'avalara_carrier_cache`');
            $buffer .= $this->_displayConfirmation('Cache cleared!');
        }
        $confValues = Configuration::getMultiple(array('AVALARATAX_ACCOUNT_NUMBER', 'AVALARATAX_LICENSE_KEY', 'AVALARATAX_URL', 'AVALARATAX_COMPANY_CODE', 'AVALARATAX_ADDRESS_VALIDATION', 'AVALARATAX_TAX_CALCULATION', 'AVALARATAX_TIMEOUT', 'AVALARATAX_ADDRESS_NORMALIZATION', 'AVALARATAX_TAX_OUTSIDE', 'AVALARATAX_COMMIT_ID', 'AVALARATAX_CANCEL_ID', 'AVALARATAX_REFUND_ID', 'AVALARATAX_POST_ID', 'AVALARA_CACHE_MAX_LIMIT', 'AVALARATAX_ADDRESS_LINE1', 'AVALARATAX_ADDRESS_LINE2', 'AVALARATAX_CITY', 'AVALARATAX_STATE', 'AVALARATAX_ZIP_CODE', 'AVALARATAX_COUNTRY'));
        $stateList = array();
        $stateList[] = array('id' => '0', 'name' => $this->l('Choose your state (if applicable)'), 'iso_code' => '--');
        foreach (State::getStates((int) $this->context->cookie->id_lang) as $state) {
            $stateList[] = array('id' => $state['id_state'], 'name' => $state['name'], 'iso_code' => $state['iso_code']);
        }
        $countryList = array();
        $countryList[] = array('id' => '0', 'name' => $this->l('Choose your country'), 'iso_code' => '--');
        foreach (Country::getCountries((int) $this->context->cookie->id_lang, false, null, false) as $country) {
            $countryList[] = array('id' => $country['id_country'], 'name' => $country['name'], 'iso_code' => $country['iso_code']);
        }
        $buffer .= '<style type="text/css">
			fieldset.avalaratax_fieldset td.avalaratax_column { padding: 0 18px; text-align: right; vertical-align: top;}
			fieldset.avalaratax_fieldset input[type=text] { width: 250px; }
			fieldset.avalaratax_fieldset input.avalaratax_button { margin-top: 10px; }
			fieldset.avalaratax_fieldset div#test_connection { margin-left: 18px; border: 1px solid #DFD5C3; padding: 5px; font-size: 11px; margin-bottom: 10px; width: 90%; }
			fieldset.avalaratax_fieldset a { color: #0000CC; font-weight: bold; text-decoration: underline; }
			.avalara-pagination {display: inline-block; float: right; }
			.avalara-pagination ul {list-style: none; display: inline-block; margin: 0; padding: 0;}
			.avalara-pagination ul li {margin-left: 10px; display: inline-block;}
			.clear {clear: both; margin: 0 auto;}
			.current-page {border: 1px solid #000; padding: 3px;}
			.orders-table {border-collapse:collapse;}
			.orders-table tr { vertical-align: top;}
			.orders-table tr td { border-top: 1px solid #000;}
		</style>
		<script type="text/javascript">
			$(function() {
				/* Add video */
				$(\'<div style="left: 567px; top: 11px; position: relative; width: 361px; height: 0px"><iframe width="360" height="215" src="http://www.youtube.com/embed/tm1tENVdcQ8" frameborder="0" allowfullscreen></iframe></div>\').prependTo(\'#content form:eq(0)\');
			});
		</script>

		<h2>' . Tools::safeOutput($this->displayName) . '</h2>
		<div class="hint clear" style="display:block;">
				<a style="float: right;" target="_blank" href="http://www.prestashop.com/en/industry-partners/management/avalara"><img alt="" src="../modules/avalaratax/avalaratax_logo.png"></a>
				<div style="width: 700px; margin: 0 auto; text-align: center"><h3 style="color: red">' . $this->l('This module is intended to work ONLY in United States of America and Canada') . '</h3></div>
				<h3>' . $this->l('How to configure Avalara Tax Module:') . '</h3>
				- ' . $this->l('Fill the Account Number, License Key, and Company Code fields with those provided by Avalara.') . ' <br />
				- ' . $this->l('Specify your origin address. This is FROM where you are shipping the products (It has to be a ') . '<b>' . $this->l('VALID UNITED STATES ADDRESS') . '</b>)<br /><br />
				<h3>' . $this->l('Module goal:') . '</h3>
//.........这里部分代码省略.........
开发者ID:rtajmahal,项目名称:PrestaShop-modules,代码行数:101,代码来源:avalaratax.php

示例8: validation

    public function validation()
    {
        if (!$this->active || !Configuration::get('GOINTERPAY_STORE') || !Configuration::get('GOINTERPAY_SECRET')) {
            return false;
        }
        if (!isset($_GET['orderId'])) {
            return false;
        }
        include_once _PS_MODULE_DIR_ . 'gointerpay/Rest.php';
        $rest = new Rest(Configuration::get('GOINTERPAY_STORE'), Configuration::get('GOINTERPAY_SECRET'));
        $result = $rest->orderDetail(Tools::safeOutput(Tools::getValue('orderId')));
        $cart = new Cart((int) $result['cartId']);
        $original_total = Tools::ps_round((double) $cart->getOrderTotal(true, Cart::BOTH), 2);
        /* Check the currency code */
        $id_currency_new = (int) Currency::getIdByIsoCode($result['foreignCurrencyCode']);
        if ($id_currency_new) {
            $cart->id_currency = (int) $id_currency_new;
            $cart->save();
        } else {
            die('Sorry, we were not able to accept orders in the following currency: ' . Tools::safeOutput($result['foreignCurrencyCode']));
        }
        $name = explode(" ", $result['delivery_address']['name']);
        $lastname = " - ";
        if (isset($name[1])) {
            $lastname = $name[1];
        }
        /* Update the delivery and billing address */
        $delivery_address = new Address((int) $cart->id_address_delivery);
        $delivery_address->firstname = $name[0];
        $delivery_address->lastname = $lastname;
        $delivery_address->company = $result['delivery_address']['company'];
        $delivery_address->phone = $result['delivery_address']['phone'];
        $delivery_address->phone_mobile = $result['delivery_address']['altPhone'];
        $delivery_address->id_country = (int) Country::getByIso($result['delivery_address']['countryCode']);
        $delivery_address->id_state = (int) State::getIdByIso($result['delivery_address']['state'], (int) $delivery_address->id_country);
        $delivery_address->address1 = $result['delivery_address']['address1'];
        $delivery_address->address2 = $result['delivery_address']['address2'];
        $delivery_address->city = $result['delivery_address']['city'];
        $delivery_address->postcode = $result['delivery_address']['zip'];
        $delivery_address->save();
        /* If no billing address specified, use the delivery address */
        if ($result['invoice_address']['address1'] != '' || $result['invoice_address']['city'] != '') {
            $invoice_name = explode(" ", $result['invoice_address']['name']);
            $invoice_lastname = " - ";
            if (isset($invoice_name[1])) {
                $invoice_lastname = $invoice_name[1];
            }
            $invoice_address = new Address((int) $cart->id_address_invoice);
            $invoice_address->firstname = $invoice_name[0];
            $invoice_address->lastname = $invoice_lastname;
            $invoice_address->company = $result['invoice_address']['company'];
            $invoice_address->phone = $result['invoice_address']['phone'];
            $invoice_address->phone_mobile = $result['invoice_address']['altPhone'];
            $invoice_address->id_country = (int) Country::getByIso($result['invoice_address']['countryCode']);
            $invoice_address->id_state = (int) State::getIdByIso($result['invoice_address']['state'], (int) $invoice_address->id_country);
            $invoice_address->address1 = $result['invoice_address']['address1'];
            $invoice_address->address2 = $result['invoice_address']['address2'];
            $invoice_address->city = $result['invoice_address']['city'];
            $invoice_address->postcode = $result['invoice_address']['zip'];
            if ($cart->id_address_delivery == $cart->id_address_invoice) {
                $invoice_address->add();
                $cart->id_address_invoice = (int) $invoice_address->id;
                $cart->save();
            } else {
                $invoice_address->save();
            }
        }
        /* Store the Order ID and Shipping cost */
        Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'gointerpay_order_id` (`id_cart`, `orderId`, `shipping`, `shipping_orig`, `taxes`, `total`, `products`, `status`)
		VALUES (\'' . (int) $cart->id . '\', \'' . pSQL(Tools::getValue('orderId')) . '\', \'' . (double) $result['shippingTotal'] . '\', \'' . (double) $result['shippingTotalForeign'] . '\', \'' . (double) $result['quotedDutyTaxes'] . '\', \'' . (double) $result['grandTotal'] . '\', \'' . (double) $result['itemsTotal'] . '\', \'Init\')');
        /* Add the duties and taxes */
        Db::getInstance()->Execute('DELETE FROM `' . _DB_PREFIX_ . 'specific_price` WHERE id_customer = ' . (int) $cart->id_customer . ' AND id_product = ' . (int) Configuration::get('GOINTERPAY_ID_TAXES_TDUTIES'));
        $specific_price = new SpecificPrice();
        $specific_price->id_product = (int) Configuration::get('GOINTERPAY_ID_TAXES_TDUTIES');
        $specific_price->id_shop = 0;
        $specific_price->id_country = 0;
        $specific_price->id_group = 0;
        $specific_price->id_cart = (int) $cart->id;
        $specific_price->id_product_attribute = 0;
        $specific_price->id_currency = $cart->id_currency;
        $specific_price->id_customer = $cart->id_customer;
        $specific_price->price = (double) $result['quotedDutyTaxesForeign'];
        $specific_price->from_quantity = 1;
        $specific_price->reduction = 0;
        $specific_price->reduction_type = 'percentage';
        $specific_price->from = date('Y-m-d H:i:s');
        $specific_price->to = strftime('%Y-%m-%d %H:%M:%S', time() + 10);
        $specific_price->add();
        if (Validate::isLoadedObject($specific_price)) {
            $cart->updateQty(1, (int) Configuration::get('GOINTERPAY_ID_TAXES_TDUTIES'));
        }
        $result['status'] = 'Pending';
        $total = Tools::ps_round((double) $cart->getOrderTotal(true, Cart::BOTH), 2);
        $message = '
		Total paid on Interpay: ' . (double) $result['grandTotalForeign'] . ' ' . (string) $result['foreignCurrencyCode'] . '
		Duties and taxes on Interpay: ' . (double) $result['quotedDutyTaxesForeign'] . ' ' . (string) $result['foreignCurrencyCode'] . '
		Shipping on Interpay: ' . (double) $result['shippingTotalForeign'] . ' ' . (string) $result['foreignCurrencyCode'] . '
		Currency: ' . $result['foreignCurrencyCode'];
        if ($result['status'] == 'Pending') {
            $this->context->cart->id = (int) $result['cartId'];
//.........这里部分代码省略.........
开发者ID:ventsiwad,项目名称:presta_addons,代码行数:101,代码来源:gointerpay.php

示例9: createAddress

 /**
  * @param $address
  * @param $customer
  * @return int
  * @throws ShopgateLibraryException
  */
 public function createAddress(ShopgateAddress $address, $customer)
 {
     /** @var AddressCore | Address $addressModel */
     $addressItem = new Address();
     $addressItem->id_customer = $customer->id;
     $addressItem->lastname = $address->getLastName();
     $addressItem->firstname = $address->getFirstName();
     if ($address->getCompany()) {
         $addressItem->company = $address->getCompany();
     }
     $addressItem->address1 = $address->getStreet1();
     if ($address->getStreet2()) {
         $addressItem->address2 = $address->getStreet2();
     }
     $addressItem->city = $address->getCity();
     $addressItem->postcode = $address->getZipcode();
     if (!Validate::isLanguageIsoCode($address->getCountry())) {
         $customer->delete();
         throw new ShopgateLibraryException(ShopgateLibraryException::REGISTER_FAILED_TO_ADD_USER, 'invalid country code: ' . $address->getCountry(), true);
     }
     $addressItem->id_country = Country::getByIso($address->getCountry());
     /**
      * prepare states
      */
     $stateParts = explode('-', $address->getState());
     if (count($stateParts) == 2) {
         $address->setState($stateParts[1]);
     }
     if ($address->getState() && !Validate::isStateIsoCode($address->getState())) {
         $customer->delete();
         throw new ShopgateLibraryException(ShopgateLibraryException::REGISTER_FAILED_TO_ADD_USER, 'invalid state code: ' . $address->getState(), true);
     } else {
         $addressItem->id_state = State::getIdByIso($address->getState());
     }
     $addressItem->alias = $address->getIsDeliveryAddress() ? $this->getModule()->l('Default delivery address') : $this->getModule()->l('Default');
     $addressItem->alias = $address->getIsInvoiceAddress() ? $this->getModule()->l('Default invoice address') : $this->getModule()->l('Default');
     $addressItem->phone = $address->getPhone();
     $addressItem->phone_mobile = $address->getMobile();
     $shopgateCustomFieldsHelper = new ShopgateCustomFieldsHelper();
     $shopgateCustomFieldsHelper->saveCustomFields($addressItem, $address->getCustomFields());
     $validateMessage = $addressItem->validateFields(false, true);
     if ($validateMessage !== true) {
         $customer->delete();
         throw new ShopgateLibraryException(ShopgateLibraryException::REGISTER_FAILED_TO_ADD_USER, $validateMessage, true);
     }
     $addressItem->save();
     return $addressItem->id;
 }
开发者ID:pankajshoffex,项目名称:shoffex_prestashop,代码行数:54,代码来源:Json.php

示例10: validateCSVRegions

 private function validateCSVRegions($csv_data, $csv_data_count)
 {
     $wrong_regions = '';
     $wrong_regions_country = '';
     for ($i = 0; $i < $csv_data_count; $i++) {
         if ($this->validateCSVCountry($csv_data[$i][DpdGroupCSV::COLUMN_COUNTRY]) && $csv_data[$i][DpdGroupCSV::COLUMN_REGION] !== '*') {
             $id_state = (int) State::getIdByIso($csv_data[$i][DpdGroupCSV::COLUMN_REGION]);
             if ($csv_data[$i][DpdGroupCSV::COLUMN_COUNTRY] === '*') {
                 $wrong_regions .= $i + self::DEFAULT_FIRST_LINE_INDEX . ', ';
             } else {
                 $id_country = (int) Country::getByIso($csv_data[$i][DpdGroupCSV::COLUMN_COUNTRY]);
                 $state = new State((int) $id_state);
                 if ($state->id_country != $id_country) {
                     $wrong_regions_country .= $i + self::DEFAULT_FIRST_LINE_INDEX . ', ';
                 }
             }
         }
     }
     $this->removeLastSymbolsFromString($wrong_regions);
     $this->removeLastSymbolsFromString($wrong_regions_country);
     return empty($wrong_regions) && empty($wrong_regions_country) ? true : array($wrong_regions, $wrong_regions_country);
 }
开发者ID:remixaz,项目名称:dpdgroup,代码行数:22,代码来源:Csv.controller.php

示例11: checkOrderStatus

 /**
  * Check Shiptotmyid status for an specific order.
  */
 public function checkOrderStatus($id_order, $result = null)
 {
     $shipto_order = ShiptomyidOrder::getByIdOrder($id_order);
     if (!Validate::isLoadedObject($shipto_order)) {
         ShiptomyidLog::addLog('invalid shiptomyid_order object', $id_order);
         return false;
     }
     if ($result === null) {
         $result = $this->api->getOrder($shipto_order->id_shiptomyid);
     }
     if (isset($result['ExternalOrder'])) {
         if ($result['ExternalOrder']['is_order_accepted'] == 'true') {
             $result_data = $result['ExternalOrder'];
             $id_country = (int) Country::getByIso($result_data['countryCode']);
             $id_state = (int) State::getIdByIso($result_data['stateCode']);
             if (!$id_state) {
                 $id_state = (int) StateCore::getIdByName($result_data['stateName']);
             }
             $data = array('firstname' => $result_data['receiver_first_name'], 'lastname' => $result_data['receiver_last_name'], 'address1' => $result_data['address_1'], 'postcode' => $result_data['zipcode'], 'city' => $result_data['city'], 'id_country' => $id_country, 'id_state' => $id_state, 'phone' => $result_data['phoneNumber']);
             $shipto_order->setDeliveryAddress($data);
             $order_state = new OrderState(self::$os_ready);
             if (Validate::isLoadedObject($order_state)) {
                 ShiptomyidOrder::changeOrderStatus($id_order, self::$os_ready);
                 ShiptomyidOrder::addMessageToOrder($id_order, $this->l('Order is ready to delivery.') . '<br/><pre>' . print_r($data, true) . '</pre>');
             }
         } elseif ($result['ExternalOrder']['is_order_rejected'] == 'true') {
             $result_data = $result['ExternalOrder'];
             $order_state = new OrderState(self::$os_cancel);
             if (Validate::isLoadedObject($order_state)) {
                 ShiptomyidOrder::changeOrderStatus($id_order, self::$os_cancel);
                 ShiptomyidOrder::addMessageToOrder($id_order, $this->l('Order is rejected : ') . $result_data['receiver_rejected_note']);
             }
         }
     } elseif (isset($result['Error'])) {
         ShiptomyidLog::addLog('Check order status error in cron task : ' . $result['Error']['message'] . ' [' . $result['Error']['status'] . ']', $id_order);
         return false;
     }
     return true;
 }
开发者ID:ship2myidpresta,项目名称:shiptomyid-1,代码行数:42,代码来源:shiptomyid.php

示例12: getStateIdByIsoCode

 /**
  * @param $isoCode
  * @return mixed
  * @throws ShopgateLibraryException
  */
 protected function getStateIdByIsoCode($isoCode)
 {
     $stateId = null;
     if ($isoCode) {
         $stateParts = explode('-', $isoCode);
         if (is_array($stateParts)) {
             if (count($stateParts) == 2) {
                 $stateId = State::getIdByIso($stateParts[1], $this->_getCountryIdByIsoCode($stateParts[0]));
             } else {
                 $stateId = State::getIdByIso($stateParts[0]);
             }
         }
         if ($stateId) {
             return $stateId;
         } else {
             $this->_addException(ShopgateLibraryException::UNKNOWN_ERROR_CODE, ' invalid or empty iso code #' . $isoCode);
         }
     }
 }
开发者ID:pankajshoffex,项目名称:shoffex_prestashop,代码行数:24,代码来源:Json.php

示例13: init


//.........这里部分代码省略.........
                         die(Tools::displayError());
                     case 'makeFreeOrder':
                         if (($id_order = $this->_checkFreeOrder()) && $id_order) {
                             $order = new Order((int) $id_order);
                             $email = $this->context->customer->email;
                             if ($this->context->customer->is_guest) {
                                 $this->context->customer->logout();
                             }
                             die('freeorder:' . $order->reference . ':' . $email);
                         }
                         exit;
                     case 'updateAddressesSelected':
                         $get_order_reference_details_request = new OffAmazonPaymentsService_Model_GetOrderReferenceDetailsRequest();
                         $get_order_reference_details_request->setSellerId(self::$amz_payments->merchant_id);
                         $get_order_reference_details_request->setAmazonOrderReferenceId(Tools::getValue('amazonOrderReferenceId'));
                         if (isset($this->context->cookie->amz_access_token)) {
                             $get_order_reference_details_request->setAddressConsentToken(AmzPayments::prepareCookieValueForAmazonPaymentsUse($this->context->cookie->amz_access_token));
                         }
                         $reference_details_result_wrapper = $this->service->getOrderReferenceDetails($get_order_reference_details_request);
                         $physical_destination = $reference_details_result_wrapper->GetOrderReferenceDetailsResult->getOrderReferenceDetails()->getDestination()->getPhysicalDestination();
                         $iso_code = (string) $physical_destination->GetCountryCode();
                         $city = (string) $physical_destination->GetCity();
                         $postcode = (string) $physical_destination->GetPostalCode();
                         $state = (string) $physical_destination->GetStateOrRegion();
                         $address_delivery = AmazonPaymentsAddressHelper::findByAmazonOrderReferenceIdOrNew(Tools::getValue('amazonOrderReferenceId'));
                         $address_delivery->id_country = Country::getByIso($iso_code);
                         $address_delivery->alias = 'Amazon Payments Delivery';
                         $address_delivery->lastname = 'amzLastname';
                         $address_delivery->firstname = 'amzFirstname';
                         $address_delivery->address1 = 'amzAddress1';
                         $address_delivery->city = $city;
                         $address_delivery->postcode = $postcode;
                         if ($state != '') {
                             $state_id = State::getIdByIso($state, Country::getByIso($iso_code));
                             if (!$state_id) {
                                 $state_id = State::getIdByName($state);
                             }
                             if ($state_id) {
                                 $address_delivery->id_state = $state_id;
                             }
                         }
                         $address_delivery->save();
                         AmazonPaymentsAddressHelper::saveAddressAmazonReference($address_delivery, Tools::getValue('amazonOrderReferenceId'));
                         $this->context->smarty->assign('isVirtualCart', $this->context->cart->isVirtualCart());
                         $old_delivery_address_id = $this->context->cart->id_address_delivery;
                         $this->context->cart->id_address_delivery = $address_delivery->id;
                         $this->context->cart->id_address_invoice = $address_delivery->id;
                         $this->context->cart->setNoMultishipping();
                         $this->context->cart->updateAddressId($old_delivery_address_id, $address_delivery->id);
                         if (!$this->context->cart->update()) {
                             $this->errors[] = Tools::displayError('An error occurred while updating your cart.');
                         }
                         $infos = Address::getCountryAndState((int) $this->context->cart->id_address_delivery);
                         if (isset($infos['id_country']) && $infos['id_country']) {
                             $country = new Country((int) $infos['id_country']);
                             $this->context->country = $country;
                         }
                         $cart_rules = $this->context->cart->getCartRules();
                         CartRule::autoRemoveFromCart($this->context);
                         CartRule::autoAddToCart($this->context);
                         if ((int) Tools::getValue('allow_refresh')) {
                             $cart_rules2 = $this->context->cart->getCartRules();
                             if (count($cart_rules2) != count($cart_rules)) {
                                 $this->ajax_refresh = true;
                             } else {
                                 $rule_list = array();
开发者ID:paeddl,项目名称:amzpayments-1,代码行数:67,代码来源:amzpayments.php

示例14: getContent

    public function getContent()
    {
        $buffer = '';
        if (version_compare(_PS_VERSION_, '1.5', '>')) {
            $this->context->controller->addJQueryPlugin('fancybox');
        } else {
            $buffer .= '<script type="text/javascript" src="' . __PS_BASE_URI__ . 'js/jquery/jquery.fancybox-1.3.4.js"></script>
		  	<link type="text/css" rel="stylesheet" href="' . __PS_BASE_URI__ . 'css/jquery.fancybox-1.3.4.css" />';
        }
        if (Tools::isSubmit('SubmitAvalaraTaxSettings')) {
            Configuration::updateValue('AVALARATAX_ACCOUNT_NUMBER', Tools::getValue('avalaratax_account_number'));
            Configuration::updateValue('AVALARATAX_LICENSE_KEY', Tools::getValue('avalaratax_license_key'));
            Configuration::updateValue('AVALARATAX_URL', Tools::getValue('avalaratax_url'));
            Configuration::updateValue('AVALARATAX_COMPANY_CODE', Tools::getValue('avalaratax_company_code'));
            $buffer .= $this->_displayConfirmation();
        } elseif (Tools::isSubmit('SubmitAvalaraTaxOptions')) {
            Configuration::updateValue('AVALARATAX_ADDRESS_VALIDATION', Tools::getValue('avalaratax_address_validation'));
            Configuration::updateValue('AVALARATAX_TAX_CALCULATION', Tools::getValue('avalaratax_tax_calculation'));
            Configuration::updateValue('AVALARATAX_TIMEOUT', (int) Tools::getValue('avalaratax_timeout'));
            Configuration::updateValue('AVALARATAX_ADDRESS_NORMALIZATION', Tools::getValue('avalaratax_address_normalization'));
            Configuration::updateValue('AVALARATAX_TAX_OUTSIDE', Tools::getValue('avalaratax_tax_outside'));
            Configuration::updateValue('AVALARA_CACHE_MAX_LIMIT', Tools::getValue('avalara_cache_max_limit') < 1 ? 1 : Tools::getValue('avalara_cache_max_limit') > 23 ? 23 : Tools::getValue('avalara_cache_max_limit'));
            $buffer .= $this->_displayConfirmation();
        } elseif (Tools::isSubmit('SubmitAvalaraTestConnection')) {
            $connectionTestResult = $this->_testConnection();
        } elseif (Tools::isSubmit('SubmitAvalaraAddressOptions')) {
            /* Validate address*/
            $address = new Address();
            $address->address1 = Tools::getValue('avalaratax_address_line1');
            $address->address2 = Tools::getValue('avalaratax_address_line2');
            $address->city = Tools::getValue('avalaratax_city');
            $address->id_state = State::getIdByIso(Tools::getValue('avalaratax_state'));
            $address->id_country = Tools::getValue('avalaratax_country');
            $address->postcode = Tools::getValue('avalaratax_zip_code');
            $normalizedAddress = $this->validateAddress($address);
            if (isset($normalizedAddress['ResultCode']) && $normalizedAddress['ResultCode'] == 'Success') {
                $buffer .= $this->_displayConfirmation($this->l('The address you submitted has been validated.'));
                Configuration::updateValue('AVALARATAX_ADDRESS_LINE1', $normalizedAddress['Normalized']['Line1']);
                Configuration::updateValue('AVALARATAX_ADDRESS_LINE2', $normalizedAddress['Normalized']['Line2']);
                Configuration::updateValue('AVALARATAX_CITY', $normalizedAddress['Normalized']['City']);
                Configuration::updateValue('AVALARATAX_STATE', $normalizedAddress['Normalized']['Region']);
                Configuration::updateValue('AVALARATAX_COUNTRY', $normalizedAddress['Normalized']['Country']);
                Configuration::updateValue('AVALARATAX_ZIP_CODE', $normalizedAddress['Normalized']['PostalCode']);
            } else {
                $message = $this->l('The following error was generated while validating your address:');
                if (isset($normalizedAddress['Exception']['FaultString'])) {
                    $message .= '<br /> - ' . Tools::safeOutput($normalizedAddress['Exception']['FaultString']);
                }
                if (isset($normalizedAddress['Messages']['Summary'])) {
                    foreach ($normalizedAddress['Messages']['Summary'] as $summary) {
                        $message .= '<br /> - ' . Tools::safeOutput($summary);
                    }
                }
                $buffer .= $this->_displayConfirmation($message, 'error');
                Configuration::updateValue('AVALARATAX_ADDRESS_LINE1', Tools::getValue('avalaratax_address_line1'));
                Configuration::updateValue('AVALARATAX_ADDRESS_LINE2', Tools::getValue('avalaratax_address_line2'));
                Configuration::updateValue('AVALARATAX_CITY', Tools::getValue('avalaratax_city'));
                Configuration::updateValue('AVALARATAX_STATE', Tools::getValue('avalaratax_state'));
                Configuration::updateValue('AVALARATAX_ZIP_CODE', Tools::getValue('avalaratax_zip_code'));
            }
        } elseif (Tools::isSubmit('SubmitAvalaraTaxClearCache')) {
            Db::getInstance()->Execute('TRUNCATE TABLE `' . _DB_PREFIX_ . 'avalara_product_cache`');
            Db::getInstance()->Execute('TRUNCATE TABLE `' . _DB_PREFIX_ . 'avalara_carrier_cache`');
            $buffer .= $this->_displayConfirmation('Cache cleared!');
        }
        $confValues = Configuration::getMultiple(array('AVALARATAX_ACCOUNT_NUMBER', 'AVALARATAX_LICENSE_KEY', 'AVALARATAX_URL', 'AVALARATAX_COMPANY_CODE', 'AVALARATAX_ADDRESS_VALIDATION', 'AVALARATAX_TAX_CALCULATION', 'AVALARATAX_TIMEOUT', 'AVALARATAX_ADDRESS_NORMALIZATION', 'AVALARATAX_TAX_OUTSIDE', 'AVALARATAX_COMMIT_ID', 'AVALARATAX_CANCEL_ID', 'AVALARATAX_REFUND_ID', 'AVALARATAX_POST_ID', 'AVALARA_CACHE_MAX_LIMIT', 'AVALARATAX_ADDRESS_LINE1', 'AVALARATAX_ADDRESS_LINE2', 'AVALARATAX_CITY', 'AVALARATAX_STATE', 'AVALARATAX_ZIP_CODE', 'AVALARATAX_COUNTRY'));
        $stateList = array();
        $stateList[] = array('id' => '0', 'name' => $this->l('Choose your state (if applicable)'), 'iso_code' => '--');
        foreach (State::getStates((int) $this->context->cookie->id_lang) as $state) {
            $stateList[] = array('id' => $state['id_state'], 'name' => $state['name'], 'iso_code' => $state['iso_code']);
        }
        $countryList = array();
        $countryList[] = array('id' => '0', 'name' => $this->l('Choose your country'), 'iso_code' => '--');
        foreach (Country::getCountries((int) $this->context->cookie->id_lang, false, null, false) as $country) {
            $countryList[] = array('id' => $country['id_country'], 'name' => $country['name'], 'iso_code' => $country['iso_code']);
        }
        $buffer .= '<link href="' . $this->_path . 'css/avalara.css" rel="stylesheet" type="text/css">
		<script type="text/javascript">
			/* Fancybox */
			$(\'a.avalara-video-btn\').live(\'click\', function(){
			    $.fancybox({
			        \'type\' : \'iframe\',
			        \'href\' : this.href.replace(new RegExp("watch\\?v=", "i"), \'embed\') + \'?rel=0&autoplay=1\',
			        \'swf\': {\'allowfullscreen\':\'true\', \'wmode\':\'transparent\'},
			        \'overlayShow\' : true,
			        \'centerOnScroll\' : true,
			        \'speedIn\' : 100,
			        \'speedOut\' : 50,
			        \'width\' : 853,
			        \'height\' : 480
			    });
			    return false;
			});
		</script>
		<script type="text/javascript">
			$(document).ready(function(){
			    var height1 = 0;
			    var height = 0;
			     $(\'.field-height1\').each(function(){
				if (height1 < $(this).height())
//.........这里部分代码省略.........
开发者ID:juniorhq88,项目名称:PrestaShop-modules,代码行数:101,代码来源:avalaratax.php

示例15: _installTaxes

 protected function _installTaxes($xml)
 {
     if (isset($xml->taxes->tax)) {
         $available_behavior = array(PS_PRODUCT_TAX, PS_STATE_TAX, PS_BOTH_TAX);
         $assoc_taxes = array();
         foreach ($xml->taxes->tax as $taxData) {
             $attributes = $taxData->attributes();
             if (Tax::getTaxIdByName($attributes['name'])) {
                 continue;
             }
             $tax = new Tax();
             $tax->name[(int) Configuration::get('PS_LANG_DEFAULT')] = strval($attributes['name']);
             $tax->rate = (double) $attributes['rate'];
             $tax->active = 1;
             if (!$tax->validateFields()) {
                 $this->_errors[] = Tools::displayError('Invalid tax properties.');
                 return false;
             }
             if (!$tax->add()) {
                 $this->_errors[] = Tools::displayError('An error occurred while importing the tax: ') . strval($attributes['name']);
                 return false;
             }
             $assoc_taxes[(int) $attributes['id']] = $tax->id;
         }
         foreach ($xml->taxes->taxRulesGroup as $group) {
             $group_attributes = $group->attributes();
             if (!Validate::isGenericName($group_attributes['name'])) {
                 continue;
             }
             if (TaxRulesGroup::getIdByName($group['name'])) {
                 continue;
             }
             $trg = new TaxRulesGroup();
             $trg->name = $group['name'];
             $trg->active = 1;
             if (!$trg->save()) {
                 $this->_errors = Tools::displayError('This tax rule cannot be saved.');
                 return false;
             }
             foreach ($group->taxRule as $rule) {
                 $rule_attributes = $rule->attributes();
                 // Validation
                 if (!isset($rule_attributes['iso_code_country'])) {
                     continue;
                 }
                 $id_country = Country::getByIso(strtoupper($rule_attributes['iso_code_country']));
                 if (!$id_country) {
                     continue;
                 }
                 if (!isset($rule_attributes['id_tax']) || !array_key_exists(strval($rule_attributes['id_tax']), $assoc_taxes)) {
                     continue;
                 }
                 // Default values
                 $id_state = (int) isset($rule_attributes['iso_code_state']) ? State::getIdByIso(strtoupper($rule_attributes['iso_code_state'])) : 0;
                 $id_county = 0;
                 $state_behavior = 0;
                 $county_behavior = 0;
                 if ($id_state) {
                     if (isset($rule_attributes['state_behavior']) && in_array($rule_attributes['state_behavior'], $available_behavior)) {
                         $state_behavior = (int) $rule_attributes['state_behavior'];
                     }
                     if (isset($rule_attributes['county_name'])) {
                         $id_county = County::getIdCountyByNameAndIdState($rule_attributes['county_name'], (int) $id_state);
                         if (!$id_county) {
                             continue;
                         }
                     }
                     if (isset($rule_attributes['county_behavior']) && in_array($rule_attributes['state_behavior'], $available_behavior)) {
                         $county_behavior = (int) $rule_attributes['county_behavior'];
                     }
                 }
                 // Creation
                 $tr = new TaxRule();
                 $tr->id_tax_rules_group = $trg->id;
                 $tr->id_country = $id_country;
                 $tr->id_state = $id_state;
                 $tr->id_county = $id_county;
                 $tr->state_behavior = $state_behavior;
                 $tr->county_behavior = $county_behavior;
                 $tr->id_tax = $assoc_taxes[strval($rule_attributes['id_tax'])];
                 $tr->save();
             }
         }
     }
     return true;
 }
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:86,代码来源:LocalizationPack.php


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