本文整理汇总了PHP中Magento\Sales\Model\Order::getBillingAddressId方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::getBillingAddressId方法的具体用法?PHP Order::getBillingAddressId怎么用?PHP Order::getBillingAddressId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Sales\Model\Order
的用法示例。
在下文中一共展示了Order::getBillingAddressId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removeEmptyAddresses
/**
* Remove empty addresses from order
*
* @param Order $order
* @return $this
*/
public function removeEmptyAddresses(Order $order)
{
if ($order->hasBillingAddressId() && $order->getBillingAddressId() === null) {
$order->unsBillingAddressId();
}
if ($order->hasShippingAddressId() && $order->getShippingAddressId() === null) {
$order->unsShippingAddressId();
}
return $this;
}
示例2: process
/**
* Process addresses saving
*
* @param Order $order
* @return $this
* @throws \Exception
*/
public function process(Order $order)
{
if (null !== $order->getAddressesCollection()) {
$order->getAddressesCollection()->save();
$billingAddress = $order->getBillingAddress();
$attributesForSave = [];
if ($billingAddress && $order->getBillingAddressId() != $billingAddress->getId()) {
$order->setBillingAddressId($billingAddress->getId());
$attributesForSave[] = 'billing_address_id';
}
$shippingAddress = $order->getShippingAddress();
if ($shippingAddress && $order->getShippigAddressId() != $shippingAddress->getId()) {
$order->setShippingAddressId($shippingAddress->getId());
$attributesForSave[] = 'shipping_address_id';
}
if (!empty($attributesForSave)) {
$this->attribute->saveAttribute($order, $attributesForSave);
}
}
return $this;
}