本文整理汇总了PHP中Zone::getZones方法的典型用法代码示例。如果您正苦于以下问题:PHP Zone::getZones方法的具体用法?PHP Zone::getZones怎么用?PHP Zone::getZones使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zone
的用法示例。
在下文中一共展示了Zone::getZones方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getContent
function getContent()
{
$configKeys = array('EBAY_SECURITY_TOKEN', 'PS_LANG_DEFAULT');
// Load prestashop ebay's configuration
$configs = Configuration::getMultiple($configKeys);
$profile_configs = $this->ebay_profile->getMultiple(array('EBAY_DELIVERY_TIME', 'EBAY_ZONE_NATIONAL', 'EBAY_ZONE_INTERNATIONAL'));
// Check if the module is configured
if (!$this->ebay_profile->getConfiguration('EBAY_PAYPAL_EMAIL')) {
$template_vars = array('error_form_shipping' => 'true');
return $this->display('error_paypal_email.tpl', $template_vars);
}
$nb_shipping_zones_excluded = DB::getInstance()->getValue('SELECT COUNT(*)
FROM ' . _DB_PREFIX_ . 'ebay_shipping_zone_excluded
WHERE `id_ebay_profile` = ' . (int) $this->ebay_profile->id);
if (!$nb_shipping_zones_excluded) {
EbayShippingZoneExcluded::loadEbayExcludedLocations($this->ebay_profile->id);
}
$module_filters = version_compare(_PS_VERSION_, '1.4.5', '>=') ? Carrier::CARRIERS_MODULE : 2;
//INITIALIZE CACHE
$psCarrierModule = $this->ebay_profile->getCarriers($configs['PS_LANG_DEFAULT'], false, false, false, null, $module_filters);
$url_vars = array('id_tab' => '3', 'section' => 'shipping');
if (version_compare(_PS_VERSION_, '1.5', '>')) {
$url_vars['controller'] = Tools::getValue('controller');
} else {
$url_vars['tab'] = Tools::getValue('tab');
}
$zones = Zone::getZones(true);
foreach ($zones as &$zone) {
$zone['carriers'] = Carrier::getCarriers($this->context->language->id, false, false, $zone['id_zone']);
}
$template_vars = array('eBayCarrier' => EbayShippingService::getCarriers($this->ebay_profile->ebay_site_id), 'psCarrier' => $this->ebay_profile->getCarriers($configs['PS_LANG_DEFAULT']), 'psCarrierModule' => $psCarrierModule, 'existingNationalCarrier' => EbayShipping::getNationalShippings($this->ebay_profile->id), 'existingInternationalCarrier' => EbayShippingInternationalZone::getExistingInternationalCarrier($this->ebay_profile->id), 'deliveryTime' => $profile_configs['EBAY_DELIVERY_TIME'], 'prestashopZone' => Zone::getZones(), 'excludeShippingLocation' => EbayShippingZoneExcluded::cacheEbayExcludedLocation($this->ebay_profile->id), 'internationalShippingLocations' => EbayShippingLocation::getInternationalShippingLocations(), 'deliveryTimeOptions' => EbayDeliveryTimeOptions::getDeliveryTimeOptions(), 'formUrl' => $this->_getUrl($url_vars), 'ebayZoneNational' => isset($profile_configs['EBAY_ZONE_NATIONAL']) ? $profile_configs['EBAY_ZONE_NATIONAL'] : false, 'ebayZoneInternational' => isset($profile_configs['EBAY_ZONE_INTERNATIONAL']) ? $profile_configs['EBAY_ZONE_INTERNATIONAL'] : false, 'ebay_token' => $configs['EBAY_SECURITY_TOKEN'], 'id_ebay_profile' => $this->ebay_profile->id, 'newPrestashopZone' => $zones);
return $this->display('shipping.tpl', $template_vars);
}
示例2: renderForm
public function renderForm()
{
if (!($obj = $this->loadObject(true))) {
return;
}
$address_layout = AddressFormat::getAddressCountryFormat($obj->id);
if ($value = Tools::getValue('address_layout')) {
$address_layout = $value;
}
$default_layout = '';
$default_layout_tab = array(array('firstname', 'lastname'), array('company'), array('vat_number'), array('address1'), array('address2'), array('postcode', 'city'), array('Country:name'), array('phone'), array('phone_mobile'));
foreach ($default_layout_tab as $line) {
$default_layout .= implode(' ', $line) . "\r\n";
}
$this->fields_form = array('legend' => array('title' => $this->l('Countries'), 'image' => '../img/admin/world.gif'), 'input' => array(array('type' => 'text', 'label' => $this->l('Country:'), 'name' => 'name', 'lang' => true, 'size' => 30, 'required' => true, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}', 'desc' => $this->l('Country name')), array('type' => 'text', 'label' => $this->l('ISO code:'), 'name' => 'iso_code', 'size' => 4, 'maxlength' => 3, 'class' => 'uppercase', 'required' => true, 'desc' => $this->l('Two -- or three -- letter ISO code (e.g. U.S. for United States)') . '.
<a href="http://www.iso.org/iso/country_codes/iso_3166_code_lists/country_names_and_code_elements.htm" target="_blank">' . $this->l('Official list here') . '
</a>.'), array('type' => 'text', 'label' => $this->l('Call prefix:'), 'name' => 'call_prefix', 'size' => 4, 'maxlength' => 3, 'class' => 'uppercase', 'required' => true, 'desc' => $this->l('International call prefix, (e.g. 1 for United States)')), array('type' => 'select', 'label' => $this->l('Default currency:'), 'name' => 'id_currency', 'options' => array('query' => Currency::getCurrencies(), 'id' => 'id_currency', 'name' => 'name', 'default' => array('label' => $this->l('Default store currency'), 'value' => 0))), array('type' => 'select', 'label' => $this->l('Zone:'), 'name' => 'id_zone', 'options' => array('query' => Zone::getZones(), 'id' => 'id_zone', 'name' => 'name'), 'desc' => $this->l('Geographical region')), array('type' => 'radio', 'label' => $this->l('Need zip/postal code:'), 'name' => 'need_zip_code', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'need_zip_code_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'need_zip_code_off', 'value' => 0, 'label' => $this->l('No')))), array('type' => 'text', 'label' => $this->l('Zip/post code format:'), 'name' => 'zip_code_format', 'class' => 'uppercase', 'required' => true, 'desc' => $this->l('Zip Code format (L for a letter, N for a number and C for the ISO code). For example, NNNNN for the United States. No verification if undefined.')), array('type' => 'address_layout', 'label' => $this->l('Address format:'), 'name' => 'address_layout', 'address_layout' => $address_layout, 'encoding_address_layout' => urlencode($address_layout), 'encoding_default_layout' => urlencode($default_layout), 'display_valid_fields' => $this->displayValidFields()), array('type' => 'radio', 'label' => $this->l('Address Standardization:'), 'name' => 'standardization', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'standardization_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'standardization_off', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'radio', 'label' => $this->l('Active:'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Display this country to your customers (the selected country will always be displayed in the Back Office)')), array('type' => 'radio', 'label' => $this->l('Contains following states:'), 'name' => 'contains_states', 'required' => false, 'class' => 't', 'values' => array(array('id' => 'contains_states_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" />' . $this->l('Yes')), array('id' => 'contains_states_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" />' . $this->l('No')))), array('type' => 'radio', 'label' => $this->l('Do you need a tax identification number?'), 'name' => 'need_identification_number', 'required' => false, 'class' => 't', 'values' => array(array('id' => 'need_identification_number_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" />' . $this->l('Yes')), array('id' => 'need_identification_number_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" />' . $this->l('No')))), array('type' => 'radio', 'label' => $this->l('Display tax label (e.g. "Tax incl."):'), 'name' => 'display_tax_label', 'required' => false, 'class' => 't', 'values' => array(array('id' => 'display_tax_label_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" />' . $this->l('Yes')), array('id' => 'display_tax_label_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" />' . $this->l('No'))))));
if (Shop::isFeatureActive()) {
$this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso');
}
$this->fields_form['submit'] = array('title' => $this->l('Save '), 'class' => 'button');
if ($this->object->iso_code == 'US') {
$this->object->standardization = Configuration::get('PS_TAASC');
}
return parent::renderForm();
}
示例3: xdInstall
public function xdInstall()
{
foreach ($this->Options->getValue('carrierList') as $carrier_key => $carrier_name) {
$carrierId = \Configuration::get($carrier_key);
$deleted = false;
if ($carrierId > 0) {
$carrier = new \Carrier($carrierId);
$deleted = $carrier->deleted;
}
if ($carrierId < 1 || $deleted) {
// Create carrier
$carrier = new \Carrier();
$carrier->name = $carrier_name;
$carrier->id_tax_rules_group = 0;
$carrier->active = 1;
$carrier->deleted = 0;
foreach (\Language::getLanguages(true) as $language) {
// TODO Carrier delay
$carrier->delay[(int) $language['id_lang']] = ' ';
}
$carrier->shipping_handling = 0;
$carrier->range_behavior = 1;
$carrier->is_module = 1;
$carrier->shipping_external = 1;
$carrier->external_module_name = $this->moduleInstance->name;
$carrier->need_range = 1;
if (!$carrier->add()) {
return false;
}
// Associate carrier to all groups
$groups = \Group::getGroups(true);
foreach ($groups as $group) {
\Db::getInstance()->insert('carrier_group', array('id_carrier' => (int) $carrier->id, 'id_group' => (int) $group['id_group']));
}
// Create price range
$rangePrice = new \RangePrice();
$rangePrice->id_carrier = $carrier->id;
$rangePrice->delimiter1 = '0';
$rangePrice->delimiter2 = '10000';
$rangePrice->add();
// Create weight range
$rangeWeight = new \RangeWeight();
$rangeWeight->id_carrier = $carrier->id;
$rangeWeight->delimiter1 = '0';
$rangeWeight->delimiter2 = '10000';
$rangeWeight->add();
// Associate carrier to all zones
$zones = \Zone::getZones(true);
foreach ($zones as $zone) {
\Db::getInstance()->insert('carrier_zone', array('id_carrier' => (int) $carrier->id, 'id_zone' => (int) $zone['id_zone']));
\Db::getInstance()->insert('delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => (int) $rangePrice->id, 'id_range_weight' => null, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'));
\Db::getInstance()->insert('delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => null, 'id_range_weight' => (int) $rangeWeight->id, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'));
}
copy(self::$instanceBaseDir . '/img/logo.jpg', _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.jpg');
\Configuration::updateValue($carrier_key, $carrier->id);
}
}
return true;
}
示例4: getSettingsPage
public function getSettingsPage()
{
$configuration_obj = new DpdPolandConfiguration();
$payment_modules = array();
foreach (DpdPoland::getPaymentModules() as $payment_module) {
$module = Module::getInstanceByName($payment_module['name']);
if (!Validate::isLoadedObject($module)) {
continue;
}
$payment_modules[] = array('displayName' => $module->displayName, 'name' => $payment_module['name']);
}
$this->context->smarty->assign(array('saveAction' => $this->module_instance->module_url, 'settings' => $configuration_obj, 'payer_numbers' => DpdPolandPayerNumber::getPayerNumbers(), 'payment_modules' => $payment_modules, 'zones' => Zone::getZones(), 'carrier_zones' => array('classic' => $this->getZonesForCarrier(DpdPolandConfiguration::CARRIER_CLASSIC_ID), 'standard' => $this->getZonesForCarrier(DpdPolandConfiguration::CARRIER_STANDARD_ID), 'standard_cod' => $this->getZonesForCarrier(DpdPolandConfiguration::CARRIER_STANDARD_COD_ID))));
if (version_compare(_PS_VERSION_, '1.6', '>=')) {
return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_ . 'admin/configuration_16.tpl');
}
return $this->context->smarty->fetch(_DPDPOLAND_TPL_DIR_ . 'admin/configuration.tpl');
}
示例5: displayForm
public function displayForm($isMainTab = true)
{
global $currentIndex, $cookie;
parent::displayForm();
if (!($obj = $this->loadObject(true))) {
return;
}
$zones = Zone::getZones(true);
$states = State::getStates((int) $cookie->id_lang);
echo '
<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post">
' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . '
<fieldset><legend><img src="../img/admin/dollar.gif" />' . $this->l('Taxes') . '</legend>
<label>' . $this->l('Name:') . ' </label>
<div class="margin-form">';
foreach ($this->_languages as $language) {
echo '
<div id="name_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;">
<input size="33" type="text" name="name_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'name', (int) $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" /><sup> *</sup>
<span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span>
</div>';
}
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name', 'name');
echo ' <p class="clear">' . $this->l('Tax name to display in cart and on invoice, e.g., VAT') . '</p>
</div>
<label>' . $this->l('Rate:') . ' </label>
<div class="margin-form">
<input type="text" size="4" maxlength="6" name="rate" value="' . htmlentities($this->getFieldValue($obj, 'rate'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
<p class="clear">' . $this->l('Format: XX.XX or XX.XXX (e.g., 19.60 or 13.925)') . '</p>
</div>
<label>' . $this->l('Enable:') . ' </label>
<div class="margin-form">
<input type="radio" name="active" id="active_on" value="1" ' . ($this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
<input type="radio" name="active" id="active_off" value="0" ' . (!$this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
</div>
<div class="margin-form">
<input type="submit" value="' . $this->l(' Save ') . '" name="submitAdd' . $this->table . '" class="button" />
</div>
<div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div>
</fieldset>
</form>';
}
示例6: renderForm
public function renderForm()
{
if (!($obj = $this->loadObject(true))) {
return;
}
$address_layout = AddressFormat::getAddressCountryFormat($obj->id);
if ($value = Tools::getValue('address_layout')) {
$address_layout = $value;
}
$default_layout = '';
$default_layout_tab = array(array('firstname', 'lastname'), array('company'), array('vat_number'), array('address1'), array('address2'), array('postcode', 'city'), array('Country:name'), array('phone'), array('phone_mobile'));
foreach ($default_layout_tab as $line) {
$default_layout .= implode(' ', $line) . "\r\n";
}
$this->fields_form = array('legend' => array('title' => $this->l('Countries'), 'icon' => 'icon-globe'), 'input' => array(array('type' => 'text', 'label' => $this->l('Country'), 'name' => 'name', 'lang' => true, 'required' => true, 'hint' => $this->l('Country name') . ' - ' . $this->l('Invalid characters:') . ' <>;=#{} '), array('type' => 'text', 'label' => $this->l('ISO code'), 'name' => 'iso_code', 'maxlength' => 3, 'class' => 'uppercase', 'required' => true, 'hint' => $this->l('Two -- or three -- letter ISO code (e.g. "us for United States).')), array('type' => 'text', 'label' => $this->l('Call prefix'), 'name' => 'call_prefix', 'maxlength' => 3, 'class' => 'uppercase', 'required' => true, 'hint' => $this->l('International call prefix, (e.g. 1 for United States).')), array('type' => 'select', 'label' => $this->l('Default currency'), 'name' => 'id_currency', 'options' => array('query' => Currency::getCurrencies(), 'id' => 'id_currency', 'name' => 'name', 'default' => array('label' => $this->l('Default store currency'), 'value' => 0))), array('type' => 'select', 'label' => $this->l('Zone'), 'name' => 'id_zone', 'options' => array('query' => Zone::getZones(), 'id' => 'id_zone', 'name' => 'name'), 'hint' => $this->l('Geographical region.')), array('type' => 'switch', 'label' => $this->l('Does it need Zip/postal code?'), 'name' => 'need_zip_code', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'need_zip_code_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'need_zip_code_off', 'value' => 0, 'label' => $this->l('No')))), array('type' => 'text', 'label' => $this->l('Zip/postal code format'), 'name' => 'zip_code_format', 'required' => true, 'desc' => $this->l('Indicate the format of the postal code: use L for a letter, N for a number, and C for the country\'s ISO 3166-1 alpha-2 code. For example, NNNNN for the United States, France, Poland and many other; LNNNNLLL for Argentina, etc. If you do not want PrestaShop to verify the postal code for this country, leave it blank.')), array('type' => 'address_layout', 'label' => $this->l('Address format'), 'name' => 'address_layout', 'address_layout' => $address_layout, 'encoding_address_layout' => urlencode($address_layout), 'encoding_default_layout' => urlencode($default_layout), 'display_valid_fields' => $this->displayValidFields()), array('type' => 'switch', 'label' => $this->l('Active'), 'name' => 'active', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'hint' => $this->l('Display this country to your customers (the selected country will always be displayed in the Back Office).')), array('type' => 'switch', 'label' => $this->l('Contains states'), 'name' => 'contains_states', 'required' => false, 'values' => array(array('id' => 'contains_states_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" />' . $this->l('Yes')), array('id' => 'contains_states_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" />' . $this->l('No')))), array('type' => 'switch', 'label' => $this->l('Do you need a tax identification number?'), 'name' => 'need_identification_number', 'required' => false, 'values' => array(array('id' => 'need_identification_number_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" />' . $this->l('Yes')), array('id' => 'need_identification_number_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" />' . $this->l('No')))), array('type' => 'switch', 'label' => $this->l('Display tax label (e.g. "Tax incl.")'), 'name' => 'display_tax_label', 'required' => false, 'values' => array(array('id' => 'display_tax_label_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" />' . $this->l('Yes')), array('id' => 'display_tax_label_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" />' . $this->l('No'))))));
if (Shop::isFeatureActive()) {
$this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association'), 'name' => 'checkBoxShopAsso');
}
$this->fields_form['submit'] = array('title' => $this->l('Save'));
return parent::renderForm();
}
示例7: addDefaultCarrierValue
/**
* Set necessaries values to the created carrier
*
* @param $id_carrier
* @param $dlv_mode
* @return bool
*/
private function addDefaultCarrierValue($id_carrier, $dlv_mode)
{
$weight_coef = $this->account_shop['MR_WEIGHT_COEFFICIENT'];
// Default Range value depending of the delivery mode
$range_weight = array('24R' => array(0, 20000 / $weight_coef), 'DRI' => array(20000 / $weight_coef, 130000 / $weight_coef), 'LD1' => array(0, 60000 / $weight_coef), 'LDS' => array(30000 / $weight_coef, 130000 / $weight_coef));
// Set range weight for a dlv_mode
if (!Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'range_weight`
(`id_carrier`, `delimiter1`, `delimiter2`)
VALUES (' . (int) $id_carrier . ', ' . $range_weight[$dlv_mode][0] . ', ' . $range_weight[$dlv_mode][1] . ')')) {
$this->_postErrors[] = $this->l('Range weight can\'t be added');
return false;
}
$range_weight_id = Db::getInstance()->Insert_ID();
// Set a range price
if (!Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'range_price`
(`id_carrier`, `delimiter1`, `delimiter2`)
VALUES (' . (int) $id_carrier . ', 0.000000, 10000.000000)')) {
$this->_postErrors[] = $this->l('Range price can\'t be added');
return false;
}
$range_price_id = Db::getInstance()->Insert_ID();
$groups = Group::getGroups(Configuration::get('PS_LANG_DEFAULT'));
foreach ($groups as $group) {
if (!Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'carrier_group`
(id_carrier, id_group)
VALUES(' . (int) $id_carrier . ', ' . (int) $group['id_group'] . ')')) {
$this->_postErrors[] = $this->l('Default zone can\'t be added');
return false;
}
}
// Set default zone
$zones = Zone::getZones();
foreach ($zones as $zone) {
if (!Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'carrier_zone`
(id_carrier, id_zone)
VALUES(' . (int) $id_carrier . ', ' . (int) $zone['id_zone'] . ')') || !Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'delivery`
(id_carrier, id_range_price, id_range_weight, id_zone, price)
VALUES(' . (int) $id_carrier . ', ' . (int) $range_price_id . ', NULL,' . (int) $zone['id_zone'] . ', 0.00)') || !Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'delivery`
(id_carrier, id_range_price, id_range_weight, id_zone, price)
VALUES(' . (int) $id_carrier . ', NULL, ' . (int) $range_weight_id . ',' . (int) $zone['id_zone'] . ', 0.00)')) {
$this->_postErrors[] = $this->l('Carrier zone or delivery data can\'t be added');
return false;
}
}
return true;
}
示例8: changeZones
public function changeZones($id)
{
$carrier = new $this->className($id);
if (!Validate::isLoadedObject($carrier)) {
die(Tools::displayError('The object cannot be loaded.'));
}
$zones = Zone::getZones(false);
foreach ($zones as $zone) {
if (count($carrier->getZone($zone['id_zone']))) {
if (!isset($_POST['zone_' . $zone['id_zone']]) || !$_POST['zone_' . $zone['id_zone']]) {
$carrier->deleteZone($zone['id_zone']);
}
} else {
if (isset($_POST['zone_' . $zone['id_zone']]) && $_POST['zone_' . $zone['id_zone']]) {
$carrier->addZone($zone['id_zone']);
}
}
}
}
示例9: createSoColissimoCarrier
public static function createSoColissimoCarrier($config)
{
$carrier = new Carrier();
$carrier->name = $config['name'];
$carrier->id_tax_rules_group = $config['id_tax_rules_group'];
$carrier->id_zone = $config['id_zone'];
$carrier->url = $config['url'];
$carrier->active = $config['active'];
$carrier->deleted = $config['deleted'];
$carrier->delay = $config['delay'];
$carrier->shipping_handling = $config['shipping_handling'];
$carrier->range_behavior = $config['range_behavior'];
$carrier->is_module = $config['is_module'];
$carrier->shipping_external = $config['shipping_external'];
$carrier->external_module_name = $config['external_module_name'];
$carrier->need_range = $config['need_range'];
$languages = Language::getLanguages(true);
foreach ($languages as $language) {
if ($language['iso_code'] == 'fr') {
$carrier->delay[$language['id_lang']] = $config['delay'][$language['iso_code']];
}
if ($language['iso_code'] == 'en') {
$carrier->delay[$language['id_lang']] = $config['delay'][$language['iso_code']];
}
}
if ($carrier->add()) {
Configuration::updateValue('SOCOLISSIMO_CARRIER_ID', (int) $carrier->id);
$groups = Group::getgroups(true);
foreach ($groups as $group) {
Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'carrier_group VALUE (\'' . (int) $carrier->id . '\',\'' . (int) $group['id_group'] . '\')');
}
$rangePrice = new RangePrice();
$rangePrice->id_carrier = $carrier->id;
$rangePrice->delimiter1 = '0';
$rangePrice->delimiter2 = '10000';
$rangePrice->add();
$rangeWeight = new RangeWeight();
$rangeWeight->id_carrier = $carrier->id;
$rangeWeight->delimiter1 = '0';
$rangeWeight->delimiter2 = '10000';
$rangeWeight->add();
$zones = Zone::getZones(true);
foreach ($zones as $zone) {
Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'carrier_zone VALUE (\'' . (int) $carrier->id . '\',\'' . (int) $zone['id_zone'] . '\')');
Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'delivery VALUE (\'\',\'' . (int) $carrier->id . '\',\'' . (int) $rangePrice->id . '\',NULL,\'' . (int) $zone['id_zone'] . '\',\'1\')');
Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'delivery VALUE (\'\',\'' . (int) $carrier->id . '\',NULL,\'' . (int) $rangeWeight->id . '\',\'' . (int) $zone['id_zone'] . '\',\'1\')');
}
//copy logo
if (!copy(dirname(__FILE__) . '/socolissimo.jpg', _PS_SHIP_IMG_DIR_ . '/' . $carrier->id . '.jpg')) {
return false;
}
return true;
} else {
return false;
}
}
示例10: changeZones
public function changeZones($id)
{
$return = true;
$carrier = new Carrier($id);
if (!Validate::isLoadedObject($carrier)) {
die($this->trans('The object cannot be loaded.', array(), 'Admin.Notifications.Error'));
}
$zones = Zone::getZones(false);
foreach ($zones as $zone) {
if (count($carrier->getZone($zone['id_zone']))) {
if (!isset($_POST['zone_' . $zone['id_zone']]) || !$_POST['zone_' . $zone['id_zone']]) {
$return &= $carrier->deleteZone((int) $zone['id_zone']);
}
} elseif (isset($_POST['zone_' . $zone['id_zone']]) && $_POST['zone_' . $zone['id_zone']]) {
$return &= $carrier->addZone((int) $zone['id_zone']);
}
}
return $return;
}
示例11: displayForm
public function displayForm()
{
global $currentIndex, $cookie;
$obj = $this->loadObject(true);
echo '
<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post">
' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . '
<fieldset class="width3"><legend><img src="../img/admin/world.gif" />' . $this->l('States') . '</legend>
<label>' . $this->l('Name:') . ' </label>
<div class="margin-form">
<input type="text" size="30" maxlength="32" name="name" value="' . htmlentities($this->getFieldValue($obj, 'name'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
<p style="clear: both;">' . $this->l('State name to display in addresses and on invoices') . '</p>
</div>
<label>' . $this->l('ISO code:') . ' </label>
<div class="margin-form">
<input type="text" size="5" maxlength="4" name="iso_code" value="' . htmlentities($this->getFieldValue($obj, 'iso_code'), ENT_COMPAT, 'UTF-8') . '" style="text-transform: uppercase;" /> <sup>*</sup>
<p>' . $this->l('1 to 4 letter ISO code') . ' (<a href="http://simple.wikipedia.org/wiki/List_of_U.S._states" target="_blank">' . $this->l('official list here') . '</a>)</p>
</div>
<label>' . $this->l('Country:') . ' </label>
<div class="margin-form">
<select name="id_country">';
$countries = Country::getCountries(intval($cookie->id_lang), false, true);
foreach ($countries as $country) {
echo '<option value="' . intval($country['id_country']) . '"' . ($this->getFieldValue($obj, 'id_country') == $country['id_country'] ? ' selected="selected"' : '') . '>' . $country['name'] . '</option>';
}
echo '
</select>
<p>' . $this->l('Country where state, region or city is located') . '</p>
</div>
<label>' . $this->l('Zone:') . ' </label>
<div class="margin-form">
<select name="id_zone">';
$zones = Zone::getZones();
foreach ($zones as $zone) {
echo '<option value="' . intval($zone['id_zone']) . '"' . ($this->getFieldValue($obj, 'id_zone') == $zone['id_zone'] ? ' selected="selected"' : '') . '>' . $zone['name'] . '</option>';
}
echo '
</select>
<p>' . $this->l('Geographical zone where this state is located') . '<br />' . $this->l('Used for shipping') . '</p>
</div>
<label>' . $this->l('Tax behavior:') . ' </label>
<div class="margin-form">
<input type="radio" name="tax_behavior" id="product_tax" value="' . PS_PRODUCT_TAX . '" ' . ((!$obj->id or $this->getFieldValue($obj, 'tax_behavior') == PS_PRODUCT_TAX) ? 'checked="checked" ' : '') . '/>
<label class="t" for="product_tax">' . $this->l('Product tax') . '</label>
<input type="radio" name="tax_behavior" id="state_tax" value="' . PS_STATE_TAX . '" ' . (($this->getFieldValue($obj, 'tax_behavior') == PS_STATE_TAX and $obj->id) ? 'checked="checked" ' : '') . '/>
<label class="t" for="state_tax">' . $this->l('State tax') . '</label>
<input type="radio" name="tax_behavior" id="both_tax" value="' . PS_BOTH_TAX . '" ' . (($this->getFieldValue($obj, 'tax_behavior') == PS_BOTH_TAX and $obj->id) ? 'checked="checked" ' : '') . '/>
<label class="t" for="both_tax">' . $this->l('Both product & state tax') . '</label>
<p>' . $this->l('Chose how tax will be applied for this state: the product\'s tax, the state\'s tax, or both.') . '</p>
</div>
<label>' . $this->l('Status:') . ' </label>
<div class="margin-form">
<input type="radio" name="active" id="active_on" value="1" ' . ((!$obj->id or $this->getFieldValue($obj, 'active')) ? 'checked="checked" ' : '') . '/>
<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
<input type="radio" name="active" id="active_off" value="0" ' . ((!$this->getFieldValue($obj, 'active') and $obj->id) ? 'checked="checked" ' : '') . '/>
<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
<p>' . $this->l('Enabled or disabled') . '</p>
</div>
<div class="margin-form">
<input type="submit" value="' . $this->l(' Save ') . '" name="submitAdd' . $this->table . '" class="button" />
</div>
<div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div>
</fieldset>
</form>';
}
示例12: displayForm
//.........这里部分代码省略.........
<div id="name_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;">
<input size="30" type="text" name="name_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'name', (int) $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" /><sup> *</sup>
<span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span>
</div>';
}
$this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name', 'name');
echo ' <p style="clear: both">' . $this->l('Name of country') . '</p>
</div>
<label>' . $this->l('ISO code:') . ' </label>
<div class="margin-form">
<input type="text" size="4" maxlength="3" name="iso_code" value="' . htmlentities($this->getFieldValue($obj, 'iso_code'), ENT_COMPAT, 'UTF-8') . '" style="text-transform: uppercase;" /> <sup>*</sup>
<p>' . $this->l('2- or 3-letter ISO code, e.g., FR for France') . '. <a href="http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html" target="_blank">' . $this->l('Official list here') . '</a>.</p>
</div>
<label>' . $this->l('Call prefix:') . ' </label>
<div class="margin-form">
<input type="text" size="4" maxlength="3" name="call_prefix" value="' . (int) $this->getFieldValue($obj, 'call_prefix') . '" style="text-transform: uppercase;" /> <sup>*</sup>
<p>' . $this->l('International call prefix, e.g., 33 for France.') . '.</p>
</div>
<label>' . $this->l('Default currency:') . ' </label>
<div class="margin-form">
<select name="id_currency">
<option value="0" ' . (Tools::getValue('id_currency', $obj->id_currency) == 0 ? 'selected' : '') . '>' . $this->l('Default store currency') . '</option>
';
$currencies = Currency::getCurrencies();
foreach ($currencies as $currency) {
echo '<option value="' . intval($currency['id_currency']) . '" ' . (Tools::getValue('id_currency', $obj->id_currency) == $currency['id_currency'] ? 'selected' : '') . '>' . Tools::htmlentitiesUTF8($currency['name']) . '</option>';
}
echo '
</select>
</div>
<label>' . $this->l('Zone:') . ' </label>
<div class="margin-form">
<select name="id_zone">';
$zones = Zone::getZones();
foreach ($zones as $zone) {
echo ' <option value="' . (int) $zone['id_zone'] . '"' . ($this->getFieldValue($obj, 'id_zone') == $zone['id_zone'] ? ' selected="selected"' : '') . '>' . $zone['name'] . '</option>';
}
$address_layout = AddressFormat::getAddressCountryFormat($obj->id);
if ($value = Tools::getValue('address_layout')) {
$address_layout = $value;
}
echo ' </select>
<p>' . $this->l('Geographical zone where country is located') . '</p>
</div>
<label>' . $this->l('Need zip code:') . ' </label>
<div class="margin-form">
<input type="radio" name="need_zip_code" id="need_zip_code_on" value="1" onchange="disableZipFormat();" ' . ((!$obj->id or $this->getFieldValue($obj, 'need_zip_code')) ? 'checked="checked" ' : '') . '/>
<label class="t" for="need_zip_code_on"> <img src="../img/admin/enabled.gif" alt="" title="' . $this->l('Yes') . '" /></label>
<input type="radio" name="need_zip_code" id="need_zip_code_off" value="0" onchange="disableZipFormat();" ' . ((!$this->getFieldValue($obj, 'need_zip_code') and $obj->id) ? 'checked="checked" ' : '') . '/>
<label class="t" for="need_zip_code_off"> <img src="../img/admin/disabled.gif" alt="" title="' . $this->l('No') . '" /></label>
</div>
<label class="zip_code_format">' . $this->l('Zip code format:') . ' </label>
<div class="margin-form zip_code_format">
<input type="text" name="zip_code_format" id="zip_code_format" value="' . $this->getFieldValue($obj, 'zip_code_format') . '" onkeyup="$(\'#zip_code_format\').val($(\'#zip_code_format\').val().toUpperCase());" /> <sup>*</sup>
<p>' . $this->l('National zip code (L for a letter, N for a number and C for the Iso code), e.g., NNNNN for France. No verification if undefined') . '.</p>
</div>
<label class="address_layout">' . $this->l('Address layout:') . ' </label>
<div class="margin-form" style="vertical-align: top;">
<div style="float:left">
<textarea id="ordered_fields" name="address_layout" style="width: 300px;height: 140px;">' . $address_layout . '</textarea>
</div>
<div style="float:left; margin-left:20px; width:340px;">
' . $this->l('Liable fields for the address information (click to have more details)') . ': ' . $this->_displayValidFields() . '
</div>
<div class="clear"></div>
<div style="margin:10px 0 10px 0;">
示例13: carrierCompatibility
private function carrierCompatibility($carrier)
{
// fix a bug in Prestashop before version 1.4.4.0 classes/cart.php function isCarrierInRange() range behavior
$rangePrices = RangePrice::getRanges($carrier->id);
if (empty($rangePrices)) {
$rangePrice = new RangePrice();
$rangePrice->id_carrier = $carrier->id;
$rangePrice->delimiter1 = 0.0;
$rangePrice->delimiter2 = 1000000.0;
if (!$rangePrice->add()) {
$this->log('installation adding rangePrice failed', ShopgateLogger::LOGTYPE_ACCESS);
return false;
}
} else {
$rangePrice = new RangeWeight($rangePrices[0]['id_range_price']);
}
$rangeWeights = RangeWeight::getRanges($carrier->id);
if (empty($rangeWeights)) {
$rangeWeight = new RangeWeight();
$rangeWeight->id_carrier = $carrier->id;
$rangeWeight->delimiter1 = 0.0;
$rangeWeight->delimiter2 = 1000000.0;
if (!$rangeWeight->add()) {
$this->log('installation adding rangeWeight failed', ShopgateLogger::LOGTYPE_ACCESS);
return false;
}
} else {
$rangeWeight = new RangeWeight($rangeWeights[0]['id_range_weight']);
}
// Zones
$zones = Zone::getZones();
foreach ($zones as $zone) {
$carrier->addZone($zone['id_zone']);
}
// create for each zone delivery options
foreach ($zones as $zone) {
$deliveryRangeWeight = new Delivery();
$deliveryRangeWeight->id_carrier = $carrier->id;
$deliveryRangeWeight->id_range_weight = $rangeWeight->id;
$deliveryRangeWeight->id_range_price = 0;
$deliveryRangeWeight->price = 0;
$deliveryRangeWeight->id_zone = $zone['id_zone'];
if (!$deliveryRangeWeight->add(true, true)) {
$this->log('installation adding deliveryRangeWeight failed', ShopgateLogger::LOGTYPE_ACCESS);
return false;
}
$deliveryRangePrice = new Delivery();
$deliveryRangePrice->id_carrier = $carrier->id;
$deliveryRangePrice->id_range_price = $rangePrice->id;
$deliveryRangePrice->id_range_weight = 0;
$deliveryRangePrice->price = 0;
$deliveryRangePrice->id_zone = $zone['id_zone'];
if (!$deliveryRangePrice->add(true, true)) {
$this->log('installation adding deliveryRangePrice failed', ShopgateLogger::LOGTYPE_ACCESS);
return false;
}
}
}
示例14: installCarriers
/**
* @return bool
* @throws Exception
* @throws PrestaShopDatabaseException
*
* @author Panagiotis Vagenas <pan.vagenas@gmail.com>
* @since ${VERSION}
*/
public function installCarriers()
{
foreach (\acsws\classes\ACSWSOptions::getInstance()->getValue('carrierList') as $carrier_key => $carrier_name) {
$carrierId = Configuration::get($carrier_key);
if ($carrierId < 1) {
// Create carrier
$carrier = new Carrier();
$carrier->name = $carrier_name;
$carrier->id_tax_rules_group = 0;
$carrier->active = 1;
$carrier->deleted = 0;
foreach (Language::getLanguages(true) as $language) {
// TODO Carrier delay
$carrier->delay[(int) $language['id_lang']] = '' . $carrier_name;
}
$carrier->shipping_handling = 1;
$carrier->range_behavior = 0;
$carrier->is_module = 1;
$carrier->shipping_external = 1;
$carrier->external_module_name = $this->name;
$carrier->need_range = 1;
if (!$carrier->add()) {
return false;
}
// Associate carrier to all groups
$groups = Group::getGroups(true);
foreach ($groups as $group) {
Db::getInstance()->insert('carrier_group', array('id_carrier' => (int) $carrier->id, 'id_group' => (int) $group['id_group']));
}
// Create price range
$rangePrice = new RangePrice();
$rangePrice->id_carrier = $carrier->id;
$rangePrice->delimiter1 = '0';
$rangePrice->delimiter2 = '10000';
$rangePrice->add();
// Create weight range
$rangeWeight = new RangeWeight();
$rangeWeight->id_carrier = $carrier->id;
$rangeWeight->delimiter1 = '0';
$rangeWeight->delimiter2 = '10000';
$rangeWeight->add();
// Associate carrier to all zones
$zones = Zone::getZones(true);
foreach ($zones as $zone) {
Db::getInstance()->insert('carrier_zone', array('id_carrier' => (int) $carrier->id, 'id_zone' => (int) $zone['id_zone']));
Db::getInstance()->insert('delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => (int) $rangePrice->id, 'id_range_weight' => null, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'));
Db::getInstance()->insert('delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => null, 'id_range_weight' => (int) $rangeWeight->id, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'));
}
copy(dirname(__FILE__) . '/img/logo.png', _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.jpg');
Configuration::updateValue($carrier_key, $carrier->id);
}
}
return true;
}
示例15: renderZones
public function renderZones($tax_rules, $id_lang)
{
$html = '';
$zones = Zone::getZones(true);
foreach ($zones as $key => $zone) {
$html .= '<div class="tab-page" id="tab-page-' . $key . '">
<h4 class="tab">' . $zone['name'] . '</h4>
<script type="text/javascript">
tabPane1.addTabPage( document.getElementById( "tab-page-' . $key . '" ) );
</script>
' . $this->renderCountries($tax_rules, $zone['id_zone'], $id_lang) . '
</div>';
}
return $html;
}