문제

I am trying to get the cart_id in my controller but it seems to only be available on the frontend in knockoutjs.

Does anyone know how to access this value which is an alpha numeric string used to place and order when calling GuestPaymentInformationManagement it passes $cart_id as a variable to the savePaymentInformationAndPlaceOrder function but I cannot find this variable in the backend but it is available on the frontend checkout as quote.quoteId() But I need to get this item in the backend if anyone knows how I'd really appreciate it.

$cart_id = 'd8sXVE1acGcxJpNnleA3e2gkSq6Zo4ae'
도움이 되었습니까?

해결책

The cart_id you are talking about corresponds to the masked quote id.

In order to get the original quote id from masked quote id you can inject the Magento\Quote\Model\QuoteIdMaskFactory in your construct method and use it like this in a controller (for example):

public function execute()
{
    $data = $this->_jsonHelper->jsonDecode($this->getRequest()->getContent());
    $maskedQuoteId = $data['quoteId'];
    $quoteIdMask = $this->quoteIdMaskFactory->create()->load($maskedQuoteId, 'masked_id');
    $quoteId = $quoteIdMask->getQuoteId();
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top