本文整理匯總了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!');
}
}
示例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!");
}
}