【问题标题】:How I get Current selected shipping address Id magneto 2.3.4我如何获得当前选择的送货地址 ID magento 2.3.4
【发布时间】:2020-03-10 20:44:22
【问题描述】:

我想在结帐页面上获得选定的运输 ID。

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
//$cart = $objectManager->get('\Magento\Checkout\Model\Cart'); 
$session = $objectManager->get('Magento\Checkout\Model\Session');
$quote = $session->getQuote();
$shippingMethod = $quote->getShippingAddress();
echo $addressId = $shippingMethod->getCustomerAddressId();

我尝试获取送货地址 ID,但当我从结帐更改波纹管图像时,它总是提供保存 ID https://drive.google.com/file/d/11N3SBaahNlugWzMw2ySAZHn4Yh4kQ64q/view

它不会改变运输 ID 显示相同。如何获取当前选定的送货地址 ID?

【问题讨论】:

  • 您是否使用过任何结帐页面的扩展程序?

标签: magento magento2


【解决方案1】:
protected $quoteRepository;

public function __construct (
   \Magento\Quote\Api\CartRepositoryInterface $quoteRepository,
) {
    $this->quoteRepository = $quoteRepository;
}

$quote = $this->quoteRepository->get($quoteId);

$addressId = $quote->getCustomerAddressId();

【讨论】:

    猜你喜欢
    • 2014-08-30
    • 1970-01-01
    • 1970-01-01
    • 2012-09-21
    • 2020-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-12
    相关资源
    最近更新 更多