Request Quote

How To Modify Existing Order Magento 2

How To Modify Existing Order Magento 2 => Today we will learn how to modify existing order at magento. sometime we need to modify existing order. that has been placed by the customer, like we need to increase or decrease the quantity , change the price etc.
so i will explain below how to do that.

$orderId = '21';
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$quoteToOrder = $objectManager

$order = $objectManager

$quote = $objectManager

first we need to update the order quote.

foreach ($items as $quoteItem) {
    $origOrderItem = $order->getItemByQuoteItemId($quoteItem->getId());
    $orderItemId = $origOrderItem->getItemId();
    //update quote item according your need 

now we have to update the order

foreach ($items as $quoteItem) {
    $orderItem = $quoteToOrder->convert($quoteItem);
    $origOrderItemNew = $order->getItemByQuoteItemId($quoteItem->getId());

    if ($origOrderItemNew) {
    } else {
        if ($quoteItem->getParentItem()) {

this is the process to modify the existing order.
hope so it will help 🙂

. . .


Add Your Comment

Be the first to comment.