I create an order programmatically like this:

$store = $this->storeManager->getStore();
$websiteId = $this->storeManager->getStore()->getWebsiteId();
$customer = $this->_customerFactory->create();
$quote = $this->quote->create();  
$customer = $this->_customerRepoInterface->getById($customer->getEntityId());

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


$shippingAddress = $quote->getShippingAddress();

$quote->getPayment()->importData(['method' => $paymentMethod]);


$order = $this->quoteManagement->submit($quote);

how can i apply coupon code in here and validate the coupon code?


Add this code to quote


after $quote->save();

| improve this answer | |
  • how to validate the coupon code ? – Tiny Dancer Jul 3 '18 at 9:15
  • I have to check – Amit Bera Jul 4 '18 at 10:36

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.