本文整理汇总了PHP中Carrier::getZones方法的典型用法代码示例。如果您正苦于以下问题:PHP Carrier::getZones方法的具体用法?PHP Carrier::getZones怎么用?PHP Carrier::getZones使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Carrier
的用法示例。
在下文中一共展示了Carrier::getZones方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initContent
public function initContent()
{
$array_carrier = array();
$carriers = Carrier::getCarriers($this->context->language->id, true, false, false, null, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
foreach ($carriers as $key => $carrier) {
if ($carrier['is_free']) {
unset($carriers[$key]);
} else {
$array_carrier[] = $carrier['id_carrier'];
}
}
$id_carrier = (int) Tools::getValue('id_carrier');
if (count($carriers) && isset($array_carrier[0])) {
if (!$id_carrier) {
$id_carrier = (int) $array_carrier[0];
}
$carrierSelected = new Carrier((int) $id_carrier);
} else {
$carrierSelected = new Carrier((int) $id_carrier);
}
$currency = $this->context->currency;
$rangeObj = $carrierSelected->getRangeObject();
$rangeTable = $carrierSelected->getRangeTable();
$suffix = $carrierSelected->getRangeSuffix();
$rangeIdentifier = 'id_' . $rangeTable;
$ranges = $rangeObj->getRanges($id_carrier);
$delivery = Carrier::getDeliveryPriceByRanges($rangeTable, $id_carrier);
$deliveryArray = array();
foreach ($delivery as $deliv) {
$deliveryArray[$deliv['id_zone']][$deliv['id_carrier']][$deliv[$rangeIdentifier]] = $deliv['price'];
}
$this->context->smarty->assign(array('zones' => $carrierSelected->getZones(), 'carriers' => $carriers, 'ranges' => $ranges, 'currency' => $currency, 'deliveryArray' => $deliveryArray, 'carrierSelected' => $carrierSelected, 'id_carrier' => $id_carrier, 'suffix' => $suffix, 'rangeIdentifier' => $rangeIdentifier, 'action_fees' => self::$currentIndex . '&token=' . $this->token));
parent::initContent();
}
示例2: add
/**
* Override add to create delivery value for all zones
* @see classes/ObjectModelCore::add()
*
* @param bool $null_values
* @param bool $autodate
* @return bool Insertion result
*/
public function add($autodate = true, $null_values = false)
{
if (!parent::add($autodate, $null_values) || !Validate::isLoadedObject($this)) {
return false;
}
$carrier = new Carrier((int) $this->id_carrier);
$price_list = array();
foreach ($carrier->getZones() as $zone) {
$price_list[] = array('id_range_price' => (int) $this->id, 'id_range_weight' => 0, 'id_carrier' => (int) $this->id_carrier, 'id_zone' => (int) $zone['id_zone'], 'price' => 0);
}
$carrier->addDeliveryPrice($price_list);
return true;
}
示例3: getTplRangesVarsAndValues
/**
* @param Carrier $carrier
* @param array $tpl_vars
* @param array $fields_value
*/
protected function getTplRangesVarsAndValues($carrier, &$tpl_vars, &$fields_value)
{
$tpl_vars['zones'] = Zone::getZones(false);
$carrier_zones = $carrier->getZones();
$carrier_zones_ids = array();
if (is_array($carrier_zones)) {
foreach ($carrier_zones as $carrier_zone) {
$carrier_zones_ids[] = $carrier_zone['id_zone'];
}
}
$range_table = $carrier->getRangeTable();
$shipping_method = $carrier->getShippingMethod();
$zones = Zone::getZones(false);
foreach ($zones as $zone) {
$fields_value['zones'][$zone['id_zone']] = Tools::getValue('zone_' . $zone['id_zone'], in_array($zone['id_zone'], $carrier_zones_ids));
}
if ($shipping_method == Carrier::SHIPPING_METHOD_FREE) {
$range_obj = $carrier->getRangeObject($carrier->shipping_method);
$price_by_range = array();
} else {
$range_obj = $carrier->getRangeObject();
$price_by_range = Carrier::getDeliveryPriceByRanges($range_table, (int) $carrier->id);
}
foreach ($price_by_range as $price) {
$tpl_vars['price_by_range'][$price['id_' . $range_table]][$price['id_zone']] = $price['price'];
}
$tmp_range = $range_obj->getRanges((int) $carrier->id);
$tpl_vars['ranges'] = array();
if ($shipping_method != Carrier::SHIPPING_METHOD_FREE) {
foreach ($tmp_range as $id => $range) {
$tpl_vars['ranges'][$range['id_' . $range_table]] = $range;
$tpl_vars['ranges'][$range['id_' . $range_table]]['id_range'] = $range['id_' . $range_table];
}
}
// init blank range
if (!count($tpl_vars['ranges'])) {
$tpl_vars['ranges'][] = array('id_range' => 0, 'delimiter1' => 0, 'delimiter2' => 0);
}
}
示例4: displayFormFees
public function displayFormFees()
{
global $currentIndex;
$carrierArray = array();
$id_carrier = Tools::getValue('id_carrier');
$carriers = Carrier::getCarriers((int) Configuration::get('PS_LANG_DEFAULT'), true, false, false, NULL, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
foreach ($carriers as $carrier) {
if (!$carrier['is_free']) {
$carrierArray[] = array('id' => $carrier['id_carrier'], 'display' => '<option value="' . (int) $carrier['id_carrier'] . '"' . ($carrier['id_carrier'] == $id_carrier ? ' selected="selected"' : '') . '>' . $carrier['name'] . '</option>');
}
}
if (count($carrierArray)) {
if (!$id_carrier) {
$id_carrier = (int) $carrierArray[0]['id'];
}
$carrierSelected = new Carrier($id_carrier);
}
echo '<br /><br />
<h2>' . $this->l('Fees by carrier, geographical zone, and ranges') . '</h2>
<form action="' . $currentIndex . '&token=' . $this->token . '" id="fees" name="fees" method="post">
<fieldset>
<legend><img src="../img/admin/delivery.gif" />' . $this->l('Fees') . '</legend>';
if (!count($carrierArray)) {
echo $this->l('You only have free carriers, there is no need to configure your delivery prices.');
} else {
echo '<b>' . $this->l('Carrier:') . ' </b>
<select name="id_carrier2" onchange="document.fees.submit();">';
foreach ($carrierArray as $carrierOption) {
echo $carrierOption['display'];
}
echo '
</select><br />
<table class="table space" cellpadding="0" cellspacing="0">
<tr>
<th>' . $this->l('Zone / Range') . '</th>';
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$rangeObj = $carrierSelected->getRangeObject();
$rangeTable = $carrierSelected->getRangeTable();
$suffix = $carrierSelected->getRangeSuffix();
$rangeIdentifier = 'id_' . $rangeTable;
$ranges = $rangeObj->getRanges($id_carrier);
$delivery = Carrier::getDeliveryPriceByRanges($rangeTable, $id_carrier);
foreach ($delivery as $deliv) {
$deliveryArray[$deliv['id_zone']][$deliv['id_carrier']][$deliv[$rangeIdentifier]] = $deliv['price'];
}
if (!$carrierSelected->is_free) {
foreach ($ranges as $range) {
echo '<th style="font-size: 11px;">' . (double) $range['delimiter1'] . $suffix . ' ' . $this->l('to') . ' ' . (double) $range['delimiter2'] . $suffix . '</th>';
}
}
echo '</tr>';
$zones = $carrierSelected->getZones();
if (sizeof($ranges) && !$carrierSelected->is_free) {
if (sizeof($zones) > 1) {
echo '
<tr>
<th style="height: 30px;">' . $this->l('All') . '</th>';
foreach ($ranges as $range) {
echo '<td class="center">' . $currency->getSign('left') . '<input type="text" id="fees_all_' . $range[$rangeIdentifier] . '" onchange="this.value = this.value.replace(/,/g, \'.\');" onkeyup="if ((event.keyCode||event.which) != 9){ spreadFees(' . $range[$rangeIdentifier] . ') }" style="width: 45px;" />' . $currency->getSign('right') . '</td>';
}
echo '</tr>';
}
foreach ($zones as $zone) {
echo '
<tr>
<th style="height: 30px;">' . $zone['name'] . '</th>';
foreach ($ranges as $range) {
if (isset($deliveryArray[$zone['id_zone']][$id_carrier][$range[$rangeIdentifier]])) {
$price = $deliveryArray[$zone['id_zone']][$id_carrier][$range[$rangeIdentifier]];
} else {
$price = '0.00';
}
echo '<td class="center">' . $currency->getSign('left') . '<input type="text" class="fees_' . $range[$rangeIdentifier] . '" onchange="this.value = this.value.replace(/,/g, \'.\');" name="fees_' . $zone['id_zone'] . '_' . $range[$rangeIdentifier] . '" onkeyup="clearAllFees(' . $range[$rangeIdentifier] . ')" value="' . $price . '" style="width: 45px;" />' . $currency->getSign('right') . '</td>';
}
echo '
</tr>';
}
}
echo '<tr>
<td colspan="' . (sizeof($ranges) + 1) . '" class="center" style="border-bottom: none; height: 40px;">
<input type="hidden" name="submitFees' . $this->table . '" value="1" />';
if (sizeof($ranges) && !$carrierSelected->is_free) {
echo ' <input type="submit" value="' . $this->l(' Save ') . '" class="button" />';
} elseif ($carrierSelected->is_free) {
echo $this->l('This is a free carrier');
} else {
echo $this->l('No ranges set for this carrier');
}
echo '
</td>
</tr>';
echo '
</table>
<p>' . $this->l('Prices do not include tax.') . '</p>';
}
echo '
</fieldset>
<input type="hidden" name="id_carrier" value="' . $id_carrier . '" />
</form>';
}
示例5: dirname
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2014 PrestaShop SA
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include dirname(__FILE__) . '/../../../config/config.inc.php';
include dirname(__FILE__) . '/../../../init.php';
include dirname(__FILE__) . '/../classes/Gateway.php';
if (Tools::getValue('token') != Tools::encrypt(Configuration::get('PS_SHOP_NAME'))) {
die(Tools::displayError());
}
$id_carrier = Tools::getValue('id_carrier');
$type = Tools::getValue('type');
if (empty($id_carrier) || empty($type)) {
die(Tools::displayError());
}
$default_val = Tools::getValue('default_val');
$carrier = new Carrier($id_carrier);
$zones = $carrier->getZones();
echo '<select name="SHIPPING_ZONE_' . strtoupper($type) . '" id="zone_' . $type . '">';
echo '<option value="" >---------</option>';
foreach ($zones as $zone) {
echo '<option value="' . $zone['id_zone'] . '" ' . ($default_val == $zone['id_zone'] ? 'selected="selected"' : '') . '>' . $zone['name'] . '</option>';
}
echo '</select>';
die;