2

i created a product with customizable options like this:

enter image description here

and i've successfully create a quote like this:

$store = $this->storeManager->getStore();
$websiteId = $this->storeManager->getStore()->getWebsiteId();
$customer = $this->_customerFactory->create();
$customer->setWebsiteId($websiteId);
$customer->loadByEmail($email); 
$quote = $this->quote->create();  
$quote->setStore($store);  
$customer = $this->_customerRepoInterface->getById($customer->getEntityId());
$quote->setCurrency();
$quote->assignCustomer($customer);  

foreach ($productsOrder as $productOrder) {
  $productId = $productOrder['product_id'];
  $qty = $productOrder['qty'];
  $product = $this->_product->load($productId);
  $price = $product->getPrice();
  $product->setPrice($price);
  $quote->addProduct(
      $product,
      intval($qty)
    );
}

$quote->getBillingAddress()->addData($address);
$quote->getShippingAddress()->addData($address);

$shippingAddress = $quote->getShippingAddress();
$shippingAddress->setCollectShippingRates(true)
  ->collectShippingRates()
  ->setShippingMethod($shippingMethod);  
$quote->setPaymentMethod($paymentMethod);  
$quote->setInventoryProcessed(false);  
$quote->save();

I need to insert the product customizable options value when i create the quote, but how to do it?

  • Old, but did you find the solution ? – Morgan Tartreau May 20 at 10:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.