且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Magento 2-在结帐会话中通过送货地址获取客户地址ID

更新时间:2023-11-30 13:04:04

您可以按以下方式获得订单 如果您尚未调用此信息,请在构造器中添加以下内容(如果尚未使用).

You can get the order as follows Whereever your want to invoke this information add following in the Constructor if not already being used.

protected $checkoutSession;
public function __construct(
        \Magento\Checkout\Model\Session $checkoutSession,
        \Psr\Log\LoggerInterface $logger
    )
    {

        $this->checkoutSession = $checkoutSession;
        $this->logger = $logger;
    }


    $order = $session->getLastRealOrder();
    $orderdata = $order->getData();
    $shipping_address_id = $orderdata['shipping_address_ID'];

此地址是付款期间选择的最终送货地址 结帐流程的阶段.

This address is the final shipping address selected during payment stage of the checkout process.