當前位置: 首頁>>代碼示例>>PHP>>正文


PHP OrderInjectable::getBillingAddressId方法代碼示例

本文整理匯總了PHP中Magento\Sales\Test\Fixture\OrderInjectable::getBillingAddressId方法的典型用法代碼示例。如果您正苦於以下問題:PHP OrderInjectable::getBillingAddressId方法的具體用法?PHP OrderInjectable::getBillingAddressId怎麽用?PHP OrderInjectable::getBillingAddressId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Sales\Test\Fixture\OrderInjectable的用法示例。


在下文中一共展示了OrderInjectable::getBillingAddressId方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setShippingInformation

 /**
  * Set shipping information to quote
  *
  * @param OrderInjectable $order
  * @throws \Exception
  */
 protected function setShippingInformation(OrderInjectable $order)
 {
     if (!$order->hasData('shipping_method')) {
         return;
     }
     $url = $this->url . '/shipping-information';
     list($carrier, $method) = explode('_', $order->getShippingMethod());
     $address = $order->hasData('shipping_address_id') ? $order->getShippingAddressId() : $order->getBillingAddressId();
     unset($address['default_billing']);
     unset($address['default_shipping']);
     foreach (array_keys($this->mappingData) as $key) {
         if (isset($address[$key])) {
             $address[$key] = $this->mappingData[$key][$address[$key]];
         }
     }
     $data = ['addressInformation' => ['shippingAddress' => $address, 'shippingMethodCode' => $method, 'shippingCarrierCode' => $carrier]];
     $this->webapiTransport->write($url, $data, WebapiDecorator::POST);
     $response = json_decode($this->webapiTransport->read(), true);
     $this->webapiTransport->close();
     if (!isset($response['payment_methods'], $response['totals'])) {
         $this->eventManager->dispatchEvent(['webapi_failed'], [$response]);
         throw new \Exception('Could not set shipping method to quote!');
     }
 }
開發者ID:VoblaSmile,項目名稱:php56-magento2-data,代碼行數:30,代碼來源:Webapi.php

示例2: setAddress

 /**
  * Set address to quote.
  *
  * @param OrderInjectable $order
  * @param string $addressType billing|shipping
  * @return void
  * @throws \Exception
  */
 protected function setAddress(OrderInjectable $order, $addressType)
 {
     $url = $this->url . "/{$addressType}-address";
     if ($addressType == 'billing') {
         $address = $order->getBillingAddressId();
     } else {
         if (!$order->hasData('shipping_method')) {
             return;
         }
         $address = $order->hasData('shipping_address_id') ? $order->getShippingAddressId() : $order->getBillingAddressId();
     }
     unset($address['default_billing']);
     unset($address['default_shipping']);
     foreach (array_keys($this->mappingData) as $key) {
         if (isset($address[$key])) {
             $address[$key] = $this->mappingData[$key][$address[$key]];
         }
     }
     $data = ["address" => $address];
     $this->webapiTransport->write($url, $data);
     $response = json_decode($this->webapiTransport->read(), true);
     $this->webapiTransport->close();
     if (!is_numeric($response)) {
         $this->eventManager->dispatchEvent(['webapi_failed'], [$response]);
         throw new \Exception("Could not set {$addressType} addresss to quote!");
     }
 }
開發者ID:whoople,項目名稱:magento2-testing,代碼行數:35,代碼來源:Webapi.php


注:本文中的Magento\Sales\Test\Fixture\OrderInjectable::getBillingAddressId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。