cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.3 add quote item as buy request

Magento 2.3 add quote item as buy request

Hello guys,

 

I want to add a quote item based on a product which has custom options and I need to add this as "info_buyRequest". 

 

Basically, I want to populate the "quote_item_option" and "quote_item" tables. So far, I managed to populate the "quote_item" table, but struggling about adding the info_buyRequest option. 

 

This is my code so far:

// quote exists
// update quote details
$quoteObj->setStoreId($storeId);
$quoteObj->assignCustomer($customerObj);
$quoteItem = $this->_quoteItem->setProduct($product)->setQty(1);
/* $additionalOptions = array(
'product_id' => 90,
'code' => 'option_14080',
'value' => '44325'
);
$quoteItem->addOption($additionalOptions);*/
$quoteObj->addItem($quoteItem);
$quoteObj->save();
 
How can I populate these tables based on the functions available in \Magento\Quote\Model\Item\Quote class? How can I add all your custom options into the quote item as BuyRequest?
2 REPLIES 2

Re: Magento 2.3 add quote item as buy request

I want to mention that the adding process is a result of an AJAX call. So, I'm not using a form.

Re: Magento 2.3 add quote item as buy request

@Anonymous 

 

Please refer below link for adding options it will surely help you as I also had once used the same and it worked for me.
http://www.blogtreat.com/magento-2-how-to-add-additional-options-in-cart-items/
If you have any question then feel free to ask!

Problem solved? Please give 'Kudos' and accept 'Answer as Solution'.