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


PHP Carrier::getDeliveryPriceByRanges方法代码示例

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


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

示例1: postProcess

 public function postProcess()
 {
     /* Shipping fees */
     if (Tools::isSubmit('submitFees' . $this->table)) {
         if ($this->tabAccess['edit'] === '1') {
             if (($id_carrier = (int) Tools::getValue('id_carrier')) && $id_carrier == ($id_carrier2 = (int) Tools::getValue('id_carrier2'))) {
                 $carrier = new Carrier($id_carrier);
                 if (Validate::isLoadedObject($carrier)) {
                     /* Get configuration values */
                     $shipping_method = $carrier->getShippingMethod();
                     $rangeTable = $carrier->getRangeTable();
                     $carrier->deleteDeliveryPrice($rangeTable);
                     $currentList = Carrier::getDeliveryPriceByRanges($rangeTable, $id_carrier);
                     /* Build prices list */
                     $priceList = array();
                     foreach ($_POST as $key => $value) {
                         if (strstr($key, 'fees_')) {
                             $tmpArray = explode('_', $key);
                             $price = number_format(abs(str_replace(',', '.', $value)), 6, '.', '');
                             $current = 0;
                             foreach ($currentList as $item) {
                                 if ($item['id_zone'] == $tmpArray[1] && $item['id_' . $rangeTable] == $tmpArray[2]) {
                                     $current = $item;
                                 }
                             }
                             if ($current && $price == $current['price']) {
                                 continue;
                             }
                             $priceList[] = array('id_range_price' => $shipping_method == Carrier::SHIPPING_METHOD_PRICE ? (int) $tmpArray[2] : null, 'id_range_weight' => $shipping_method == Carrier::SHIPPING_METHOD_WEIGHT ? (int) $tmpArray[2] : null, 'id_carrier' => (int) $carrier->id, 'id_zone' => (int) $tmpArray[1], 'price' => $price);
                         }
                     }
                     /* Update delivery prices */
                     $carrier->addDeliveryPrice($priceList);
                     Tools::redirectAdmin(self::$currentIndex . '&conf=6&id_carrier=' . $carrier->id . '&token=' . $this->token);
                 } else {
                     $this->errors[] = Tools::displayError('An error occurred while attempting to update fees (cannot load carrier object).');
                 }
             } elseif (isset($id_carrier2)) {
                 $_POST['id_carrier'] = $id_carrier2;
             } else {
                 $this->errors[] = Tools::displayError('An error occurred while attempting to update fees (cannot load carrier object).');
             }
         } else {
             $this->errors[] = Tools::displayError('You do not have permission to edit this.');
         }
     } else {
         return parent::postProcess();
     }
 }
开发者ID:IngenioContenidoDigital,项目名称:americana,代码行数:49,代码来源:AdminShippingController.php

示例2: 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);
     }
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:44,代码来源:AdminCarrierWizardController.php

示例3: 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>';
    }
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:100,代码来源:AdminShipping.php

示例4: displayFormFees

    public function displayFormFees()
    {
        global $currentIndex;
        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" class="width2">
			<fieldset>
				<legend><img src="../img/admin/delivery.gif" />' . $this->l('Fees') . '</legend>
				<b>' . $this->l('Carrier:') . ' </b>
				<select name="id_carrier2" onchange="document.fees.submit();">';
        $carriers = Carrier::getCarriers(intval(Configuration::get('PS_LANG_DEFAULT')));
        $id_carrier = Tools::getValue('id_carrier') ? intval(Tools::getValue('id_carrier')) : intval($carriers[0]['id_carrier']);
        $carrierSelected = new Carrier($id_carrier);
        foreach ($carriers as $carrier) {
            echo '<option value="' . intval($carrier['id_carrier']) . '"' . ($carrier['id_carrier'] == $id_carrier ? ' selected="selected"' : '') . '>' . $carrier['name'] . '</option>';
        }
        echo '
				</select><br />
				<table class="table space" cellpadding="0" cellspacing="0">
					<tr>
						<th>' . $this->l('Zone / Range') . '</th>';
        $shipping_method = intval(Configuration::get('PS_SHIPPING_METHOD'));
        $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
        $rangeObj = $shipping_method ? new RangeWeight() : new RangePrice();
        $rangeTable = $shipping_method ? 'range_weight' : 'range_price';
        $rangeIdentifier = 'id_' . $rangeTable;
        $ranges = $rangeObj->getRanges($id_carrier);
        $suffix = $shipping_method ? Configuration::get('PS_WEIGHT_UNIT') : $currency->sign;
        $delivery = Carrier::getDeliveryPriceByRanges($rangeTable);
        foreach ($delivery as $deliv) {
            $deliveryArray[$deliv['id_zone']][$deliv['id_carrier']][$deliv[$rangeIdentifier]] = $deliv['price'];
        }
        foreach ($ranges as $range) {
            echo '<th style="font-size: 11px;">' . floatval($range['delimiter1']) . $suffix . ' ' . $this->l('to') . ' ' . floatval($range['delimiter2']) . $suffix . '</th>';
        }
        echo '</tr>';
        $zones = Zone::getZones(true);
        if (sizeof($ranges)) {
            foreach ($zones as $zone) {
                if (!$carrierSelected->getZone($zone['id_zone'])) {
                    continue;
                }
                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" name="fees_' . $zone['id_zone'] . '_' . $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)) {
            echo '	<input type="submit" value="' . $this->l('   Save   ') . '" class="button" />';
        } else {
            echo $this->l('No ranges set for this carrier');
        }
        echo '
						</td>
					</tr>';
        echo '
				</table>
				<p>' . $this->l('Prices are tax excluded.') . '</p>
			</fieldset>
			<input type="hidden" name="id_carrier" value="' . $id_carrier . '" />
		</form>';
    }
开发者ID:Bruno-2M,项目名称:prestashop,代码行数:77,代码来源:AdminShipping.php


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