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


PHP Zone::get_zones_for_address方法代码示例

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


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

示例1: calculateRate

 function calculateRate(ShippingPackage $package, $address)
 {
     $rate = null;
     $ids = Zone::get_zones_for_address($address);
     if (!$ids) {
         return $rate;
     }
     $ids = $ids->map('ID', 'ID');
     $packageconstraints = array("Weight" => 'weight', "Volume" => 'volume', "Value" => 'value', "Quantity" => 'quantity');
     $constraintfilters = array();
     foreach ($packageconstraints as $db => $pakval) {
         $mincol = "\"ZonedShippingRate\".\"{$db}Min\"";
         $maxcol = "\"ZonedShippingRate\".\"{$db}Max\"";
         $constraintfilters[] = "(" . "{$mincol} >= 0" . " AND {$mincol} <= " . $package->{$pakval}() . " AND {$maxcol} > 0" . " AND {$maxcol} >= " . $package->{$pakval}() . " AND {$mincol} < {$maxcol}" . ")";
     }
     $filter = "(" . implode(") AND (", array("\"ZonedShippingMethodID\" = " . $this->ID, "\"ZoneID\" IN(" . implode(",", $ids) . ")", implode(" OR ", $constraintfilters))) . ")";
     //order by zone specificity
     $orderby = "";
     if (count($ids) > 1) {
         $orderby = "CASE \"ZonedShippingRate\".\"ZoneID\"";
         $count = 1;
         foreach ($ids as $id) {
             $orderby .= " WHEN {$id} THEN {$count} ";
             $count++;
         }
         $orderby .= "ELSE {$count} END ASC,";
     }
     $orderby .= "\"ZonedShippingRate\".\"Rate\" ASC";
     if ($sr = DataObject::get_one("ZonedShippingRate", $filter, true, $orderby)) {
         $rate = $sr->Rate;
     }
     $this->CalculatedRate = $rate;
     return $rate;
 }
开发者ID:tylerkidd,项目名称:silverstripe-shop-shippingframework,代码行数:34,代码来源:ZonedShippingMethod.php

示例2: check

 public function check(Discount $discount)
 {
     $zones = $discount->Zones();
     if (!$zones->exists()) {
         return true;
     }
     $address = $this->order->getShippingAddress();
     if (!$address) {
         $this->error(_t("OrderCouponModifier.NOTINZONE", "This coupon can only be used for a specific shipping location."));
         return false;
     }
     $currentzones = Zone::get_zones_for_address($address);
     if (!$currentzones || !$currentzones->exists()) {
         $this->error(_t("OrderCouponModifier.NOTINZONE", "This discount can only be used for a specific shipping location."));
         return false;
     }
     //check if any of currentzones is in zones
     $inzone = false;
     foreach ($currentzones as $zone) {
         if ($zones->find('ID', $zone->ID)) {
             $inzone = true;
             break;
         }
     }
     if (!$inzone) {
         $this->error(_t("OrderCouponModifier.NOTINZONE", "This discount can only be used for a specific shipping location."));
         return false;
     }
     return true;
 }
开发者ID:helpfulrobot,项目名称:silvershop-discounts,代码行数:30,代码来源:ZonesDiscountConstraint.php

示例3: assertNoZoneMatch

 public function assertNoZoneMatch($address)
 {
     $zones = Zone::get_zones_for_address($address);
     $this->assertFalse($zones->exists(), "No zones exist");
 }
开发者ID:helpfulrobot,项目名称:silvershop-core,代码行数:5,代码来源:ZoneTest.php


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