0

I want to modify the values of the product items will be inserted to table 'sales_order_item' right before the order is placed.

So im trying to locate where the exact query is.

Also the order confirmation mail should sent the modified item values not the original.

0

So i basically solved this by adding my code to public_html/vendor/magento/module-checkout/view/frontend/templates/success.phtml

So it gets updated only once and not everytime when the order is saved in the backend. If you want to see what code i have put there, then here you go

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$resource = $objectManager->get('Magento\Framework\App\ResourceConnection');
$connection = $resource->getConnection();

$sqlx = "SELECT * FROM sales_order ORDER BY entity_id DESC LIMIT 1";
$connection->query($sqlx);
$resultx = $connection->fetchAll($sqlx);
foreach($resultx as $resulx)
{
    $entityid  = $resulx['entity_id']; 
}

$sql = "SELECT * FROM sales_order_item WHERE order_id='$entityid'";
$connection->query($sql);
$results = $connection->fetchAll($sql);

foreach($results as $result)
{
    $item_id = $result['item_id'];

    /* DO WHATEVER YOU WANT HERE */     

    $upsql = "UPDATE sales_order_item SET product_options='$finalque' WHERE item_id='$item_id'";
    $connection->query($upsql);
    }
}

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.