I have added a field for the cart graphql called cart_updated in the response interface which is a boolean value (true/false) using my custom resolver. If Custom Price for any quote item is set then it will return true else false.
Now the issue is I have used the below code for setting the custom price for Quote Item. When I am hitting the cart query API the first time it is only setting the original custom price in the DB table but not updating the row total, subtotal, etc.
But when I am hitting the cart query the 2nd time after that it is updating the row total, subtotal, etc.
Here is my code -
// This is the cart object which is coming in the cart query response
$cart = $value['model'];
$cartUpdated = false;
$cartItems = $cart->getAllVisibleItems();
/** @var QuoteItem $cartItem */
foreach ($cartItems as $cartItem) {
$cartItemPrice = $cartItem->getOriginalCustomPrice();
$currentPrice = 2008.98;
// Here I am comparing the quote item price in DB and price from my custom table.
//If they are not same then only I am updating the price.
if ($currentPrice && $cartItemPrice != $currentPrice) {
$cartItem->setOriginalCustomPrice($currentPrice);
$cartItem->setCustomPrice($currentPrice);
$cartUpdated = true;
}
}
$this->cart->save();
return $cartUpdated;
Please help.