I want to update the cart items using my custom API with the latest price which I am storing in a custom table.
In the first API hit it is only updating the original custom price in the item table but not updating anything else.
But when I hit the API for 2nd time it is updating the price and subtotal correctly with the custom price.
Here is my code –
$cartItems = $cart->getAllVisibleItems();
foreach ($cartItems as $cartItem) {
$cartItem->setOriginalCustomPrice($my-price);
$cartItem->setCustomPrice($my-price);
$cartUpdated = true;
}
}
$this->cartRepository->save($quote);
Please help.