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


PHP Zone::cache_zone_ids方法代码示例

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


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

示例1: testLocalRates

 function testLocalRates()
 {
     $address_loc = $this->objFromFixture("Address", "wnz6022");
     //New Zealand address
     Zone::cache_zone_ids($address_loc);
     //weight based
     $type = "weight";
     $this->assertMatch($type, $this->p0, $address_loc, 4);
     //weight = 0kg
     $this->assertMatch($type, $this->p1, $address_loc, 4);
     //weight = 2.34kg
     $this->assertMatch($type, $this->p2, $address_loc, 48);
     //weight= 17kg,
     $this->assertMatch($type, $this->p3, $address_loc, 58);
     //weight = 100kg
     $this->assertNoMatch($type, $this->p4, $address_loc);
     //weight = 1000kg
     //volume based
     $type = "volume";
     $this->assertMatch($type, $this->p0, $address_loc, 1);
     //volume = 0cm3
     $this->assertMatch($type, $this->p1, $address_loc, 1);
     //volume = 1cm3
     $this->assertMatch($type, $this->p2, $address_loc, 3);
     //volume = 6cm3
     $this->assertMatch($type, $this->p3, $address_loc, 520);
     //volume = 18927.783cm3
     $this->assertNoMatch($type, $this->p4, $address_loc);
     //volume = 2000000cm3
     //value based
     $type = "value";
     $this->assertMatch($type, $this->p0, $address_loc, 1);
     //value = $0
     $this->assertMatch($type, $this->p1, $address_loc, 1);
     //value = $2
     $this->assertMatch($type, $this->p2, $address_loc, 3);
     //value = $6
     $this->assertNoMatch($type, $this->p3, $address_loc);
     //value = $1000
     $this->assertNoMatch($type, $this->p4, $address_loc);
     //value = $1,000,000
     //quantity based
     $type = "quantity";
     $this->assertNoMatch($type, $this->p0, $address_loc);
     //quantity = 0
     $this->assertMatch($type, $this->p1, $address_loc, 5.5);
     //quantity = 3
     $this->assertMatch($type, $this->p2, $address_loc, 9.300000000000001);
     //quantity = 10
     $this->assertNoMatch($type, $this->p3, $address_loc);
     //quantity = 155
     $this->assertNoMatch($type, $this->p4, $address_loc);
     //quantity = 12412
 }
开发者ID:nimeso,项目名称:silverstripe-shop-shippingframework,代码行数:54,代码来源:ZonedShippingMethodTest.php

示例2: setShippingAddress

 public function setShippingAddress(Address $address)
 {
     $this->order->ShippingAddressID = $address->ID;
     if (Member::currentUserID()) {
         $this->order->MemberID = Member::currentUserID();
     }
     $this->order->write();
     $this->order->extend('onSetShippingAddress', $address);
     //update zones and userinfo
     ShopUserInfo::singleton()->setAddress($address);
     Zone::cache_zone_ids($address);
 }
开发者ID:NobrainerWeb,项目名称:silverstripe-shop,代码行数:12,代码来源:Checkout.php

示例3: setData

 /**
  * Create a new address if the existing address has changed, or is not yet
  * created.
  *
  * @param Order $order order to get addresses from
  * @param array $data  data to set
  */
 public function setData(Order $order, array $data)
 {
     $address = $this->getAddress($order);
     //if the value matches the current address then unset
     //this is to fix issues with blank fields & the readonly Country field
     $addressfields = Address::database_fields(get_class($address));
     foreach ($data as $key => $value) {
         if (!isset($addressfields[$key]) || !$value && !$address->{$key}) {
             unset($data[$key]);
         }
     }
     $address->update($data);
     //if only one country is available, then set it
     if ($country = SiteConfig::current_site_config()->getSingleCountry()) {
         $address->Country = $country;
     }
     //write new address, or duplicate if changed
     if (!$address->isInDB()) {
         $address->write();
     } elseif ($address->isChanged()) {
         $address = $address->duplicate();
     }
     //set billing address, if not already set
     $order->{$this->addresstype . "AddressID"} = $address->ID;
     if (!$order->BillingAddressID) {
         $order->BillingAddressID = $address->ID;
     }
     $order->write();
     //update user info based on shipping address
     if ($this->addresstype === "Shipping") {
         ShopUserInfo::singleton()->setAddress($address);
         Zone::cache_zone_ids($address);
     }
     //associate member to address
     if ($member = Member::currentUser()) {
         $default = $member->{"Default" . $this->addresstype . "Address"}();
         //set default address
         if (!$default->exists()) {
             $member->{"Default" . $this->addresstype . "AddressID"} = $address->ID;
             $member->write();
         }
         if ($this->addtoaddressbook) {
             $member->AddressBook()->add($address);
         }
     }
     //extension hooks
     $order->extend('onSet' . $this->addresstype . 'Address', $address);
 }
开发者ID:burnbright,项目名称:silverstripe-shop,代码行数:55,代码来源:AddressCheckoutComponent.php

示例4: setData

 /**
  * Create a new address if the existing address has changed, or is not yet 
  * created.
  *
  * @param Order $order order to get addresses from
  * @param array $data  data to set
  */
 public function setData(Order $order, array $data)
 {
     $address = $this->getAddress($order);
     $address->update($data);
     //if only one country is available, then set it
     if ($country = SiteConfig::current_site_config()->getSingleCountry()) {
         $address->Country = $country;
     }
     //write new address, or duplicate if changed
     if (!$address->isInDB()) {
         $address->write();
     } elseif ($address->isChanged()) {
         $address = $address->duplicate();
     }
     //set billing address, if not already set
     $order->{$this->addresstype . "AddressID"} = $address->ID;
     if (!$order->BillingAddressID) {
         $order->BillingAddressID = $address->ID;
     }
     $order->write();
     //update user info based on shipping address
     if ($this->addresstype === "Shipping") {
         ShopUserInfo::singleton()->setAddress($address);
         Zone::cache_zone_ids($address);
     }
     //associate member to address
     if ($member = Member::currentUser()) {
         $default = $member->{"Default" . $this->addresstype . "Address"}();
         //set default address
         if (!$default->exists()) {
             $member->{"Default" . $this->addresstype . "AddressID"} = $address->ID;
             $member->write();
         }
         if ($this->addtoaddressbook) {
             $member->AddressBook()->add($address);
         }
     }
     //extension hooks
     $order->extend('onSet' . $this->addresstype . 'Address', $address);
 }
开发者ID:helpfulrobot,项目名称:silvershop-core,代码行数:47,代码来源:AddressCheckoutComponent.php

示例5: setData

 public function setData(Order $order, array $data)
 {
     if (!isset($data['Use'])) {
         parent::setData($order, $data);
         return;
     }
     $member = Member::currentUser() ?: $order->Member();
     if (strpos($data['Use'], 'address-') === 0) {
         $address = Address::get()->byID(substr($data['Use'], 8));
         if (!$address) {
             throw new ValidationException('That address does not exist');
         }
         if (isset($data[$data['Use']]) && isset($data[$data['Use']]['saveAsNew']) && $data[$data['Use']]['saveAsNew']) {
             if (!$address->canCreate()) {
                 throw new ValidationException('You do not have permission to add a new address');
             }
             $address = $address->duplicate();
         } else {
             if (isset($data[$data['Use']]) && !$address->canEdit() && $address->MemberID != $member->ID) {
                 throw new ValidationException('You do not have permission to use this address');
             }
         }
     } else {
         if (!singleton('Address')->canCreate()) {
             throw new ValidationException('You do not have permission to add a new address');
         }
         $address = Address::create();
     }
     if (isset($data[$data['Use']])) {
         $address->castedUpdate($data[$data['Use']]);
         // FIX for missing name fields
         $fields = array_intersect_key($data, array_flip(['FirstName', 'Surname', 'Name', 'Email']));
         foreach ($fields as $field => $value) {
             if (!$address->{$field}) {
                 $address->{$field} = $value;
             }
         }
         if ($country = ShopConfig::current()->SingleCountry) {
             $address->Country = $country;
         }
         if ($this->addtoaddressbook) {
             $address->MemberID = $member->ID;
         }
         $address->write();
         if (isset($data[$data['Use']]['useAsDefaultShipping']) && $data[$data['Use']]['useAsDefaultShipping']) {
             $member->DefaultShippingAddressID = $address->ID;
         }
         if (isset($data[$data['Use']]['useAsDefaultBilling']) && $data[$data['Use']]['useAsDefaultBilling']) {
             $member->DefaultBillingAddressID = $address->ID;
         }
         if ($member->isChanged()) {
             $member->write();
         }
     }
     if ($address->exists()) {
         if ($this->addresstype === 'Shipping') {
             ShopUserInfo::singleton()->setAddress($address);
             Zone::cache_zone_ids($address);
         }
         $order->{$this->addresstype . 'AddressID'} = $address->ID;
         if (!$order->BillingAddressID) {
             $order->BillingAddressID = $address->ID;
         }
         $order->write();
         $order->extend('onSet' . $this->addresstype . 'Address', $address);
     }
 }
开发者ID:milkyway-multimedia,项目名称:ss-shop-checkout-extras,代码行数:67,代码来源:AlternateAddressBookCheckoutComponent.php


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