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


PHP State::getStatesByCountry方法代码示例

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


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

示例1: getStates

 private function getStates(DeliveryZone $zone, $country)
 {
     $localeInfo = $this->locale->info();
     $allCountries = $countries = $localeInfo->getAllCountries();
     $allStates = array();
     foreach (State::getStatesByCountry($country) as $stateID => $state) {
         $allStates[$stateID] = $localeInfo->getCountryName($country) . ": " . $state;
     }
     $selectedStates = array();
     foreach ($zone->getStates()->toArray() as $state) {
         $selectedStates[$state['State']['ID']] = $localeInfo->getCountryName($state['State']['countryID']) . ": " . $state['State']['name'];
         unset($allStates[$state['State']['ID']]);
     }
     return array('all' => $allStates, 'selected' => $selectedStates);
 }
开发者ID:saiber,项目名称:www,代码行数:15,代码来源:DeliveryZoneController.php

示例2: editAddress

 public function editAddress()
 {
     $this->loadLanguageFile('backend/CustomerOrder');
     ClassLoader::import('application.controller.backend.CustomerOrderController');
     $shipment = Shipment::getInstanceByID('Shipment', $this->request->get('id'), true, array('CustomerOrder', 'User'));
     if (!$shipment->shippingAddress->get()) {
         $shipment->shippingAddress->set(UserAddress::getNewInstance());
         $shipment->shippingAddress->get()->save();
     }
     $shipment->shippingAddress->get()->load();
     $address = $shipment->shippingAddress->get()->toArray();
     $response = new ActionResponse();
     $controller = new CustomerOrderController($this->application);
     $response->set('form', $controller->createUserAddressForm($address, $response));
     $response->set('countries', $this->application->getEnabledCountries());
     $response->set('states', State::getStatesByCountry($address['countryID']));
     $response->set('shipmentID', $shipment->getID());
     $addressOptions = array('' => '');
     $addresses = array();
     foreach (array_merge($shipment->order->get()->user->get()->getShippingAddressArray(), $shipment->order->get()->user->get()->getBillingAddressArray()) as $address) {
         $addressOptions[$address['ID']] = $address['UserAddress']['compact'];
         $addresses[$address['ID']] = $address;
     }
     $response->set('existingUserAddressOptions', $addressOptions);
     $response->set('existingUserAddresses', $addresses);
     return $response;
 }
开发者ID:saiber,项目名称:www,代码行数:27,代码来源:ShipmentController.php

示例3: states

 /**
  *  Return a list of states for the selected country
  *  @return JSONResponse
  */
 public function states()
 {
     $states = State::getStatesByCountry($this->request->get('country'));
     return new JSONResponse($states);
 }
开发者ID:saiber,项目名称:livecart,代码行数:9,代码来源:UserController.php

示例4: getStateList

 protected function getStateList($country)
 {
     $states = State::getStatesByCountry($country);
     if ($states) {
         $states = array('' => '') + $states;
     }
     return $states;
 }
开发者ID:saiber,项目名称:www,代码行数:8,代码来源:FrontendController.php

示例5: info

 public function info()
 {
     $this->loadLanguageFile('backend/Shipment');
     $order = CustomerOrder::getInstanceById((int) $this->request->get('id'), true, array('User', 'Currency'));
     $order->getSpecification();
     $order->loadAll();
     $this->removeEmptyShipments($order);
     $response = new ActionResponse();
     $this->assignStatuses($response);
     $response->set('countries', $this->application->getEnabledCountries());
     $orderArray = $order->toArray();
     if ($order->isFinalized->get()) {
         if ($billingAddress = $order->billingAddress->get()) {
             $billingAddress->load(true);
             $orderArray['BillingAddress'] = $billingAddress->toArray();
         }
         if ($shippingAddress = $order->shippingAddress->get()) {
             $shippingAddress->load(true);
             $orderArray['ShippingAddress'] = $shippingAddress->toArray();
         }
         if ($order->billingAddress->get()) {
             $billingStates = State::getStatesByCountry($order->billingAddress->get()->countryID->get());
             $billingStates[''] = '';
             asort($billingStates);
             $response->set('billingStates', $billingStates);
         }
         if ($order->shippingAddress->get()) {
             $shippingStates = State::getStatesByCountry($order->shippingAddress->get()->countryID->get());
             $shippingStates[''] = '';
             asort($shippingStates);
             $response->set('shippingStates', $shippingStates);
         }
     } elseif ($order->user->get()) {
         $order->user->get()->loadAddresses();
         if (!$order->shippingAddress->get() && $order->user->get()->defaultShippingAddress->get()) {
             $shippingStates = State::getStatesByCountry($order->user->get()->defaultShippingAddress->get()->userAddress->get()->countryID->get());
             $orderArray['ShippingAddress'] = $order->user->get()->defaultShippingAddress->get()->userAddress->get()->toArray();
         }
         $shippingStates[''] = '';
         if (!$order->billingAddress->get() && $order->user->get()->defaultBillingAddress->get()) {
             $billingStates = State::getStatesByCountry($order->user->get()->defaultBillingAddress->get()->userAddress->get()->countryID->get());
             $orderArray['BillingAddress'] = $order->user->get()->defaultBillingAddress->get()->userAddress->get()->toArray();
         }
         $billingStates[''] = '';
         $response->set('shippingStates', $shippingStates);
         $response->set('billingStates', $billingStates);
     }
     $response->set('order', $orderArray);
     $response->set('form', $this->createOrderForm($orderArray));
     $user = $order->user->get();
     $response->setStatusCode(200);
     if ($user) {
         $addressOptions = array('' => '');
         $addressOptions['optgroup_0'] = $this->translate('_billing_addresses');
         $addresses = array();
         foreach ($user->getBillingAddressArray() as $address) {
             $addressOptions[$address['ID']] = $this->createAddressString($address);
             $addresses[$address['ID']] = $address;
         }
         $addressOptions['optgroup_1'] = $this->translate('_shipping_addresses');
         foreach ($user->getShippingAddressArray() as $address) {
             $addressOptions[$address['ID']] = $this->createAddressString($address);
             $addresses[$address['ID']] = $address;
         }
         $response->set('existingUserAddressOptions', $addressOptions);
         $response->set('existingUserAddresses', $addresses);
     }
     foreach (array('ShippingAddress', 'BillingAddress') as $type) {
         $response->set('form' . $type, $this->createUserAddressForm(isset($orderArray[$type]) ? $orderArray[$type] : array(), $response));
     }
     $shipableShipmentsCount = 0;
     $hideShipped = 0;
     $hasDownloadable = false;
     foreach ($order->getShipments() as $shipment) {
         if ($shipment->isShipped()) {
             continue;
         }
         if (!$shipment->isShippable() && count($shipment->getItems()) > 0) {
             continue;
         }
         if ($shipment->status->get() != Shipment::STATUS_SHIPPED && $shipment->isShippable()) {
             $shipableShipmentsCount++;
         }
         $rate = unserialize($shipment->shippingServiceData->get());
         if (count($shipment->getItems()) == 0 || !is_object($rate) && !$shipment->shippingService->get()) {
             $hideShipped = 1;
             break;
         }
     }
     BackendToolbarItem::registerLastViewedOrder($order);
     //		$response->set('hideShipped', $shipableShipmentsCount > 0 ? $hideShipped : 1);
     $response->set('hideShipped', false);
     $response->set('type', $this->getOrderType($order));
     // custom fields
     $form = $this->createFieldsForm($order);
     $order->getSpecification()->setFormResponse($response, $form);
     $response->set('fieldsForm', $form);
     $this->appendCalendarForm($response);
     return $this->shipmentInfo($response);
 }
开发者ID:saiber,项目名称:livecart,代码行数:100,代码来源:CustomerOrderController.php


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