0

I'm trying to remove an item from the cart, but I need to remove it on the payment page (checkout)

I'm using the following code

$cartHelper = Mage::helper('checkout/cart');
$cartItemId = 651;
$cartHelper->getCart()->removeItem($cartItemId)->save();

but the product is not removed, am I doing it wrong? I saw that there is a URL to delete the item from the checkout page checkout/cart/delete/id/

but I don't know how to execute this, as soon as I load the page, can anyone help me?

1 Answer 1

1

Try to delete it from the Quote instead of the Cart since you are past the Cart page already.

$quote = Mage::getSingleton('checkout/session')->getQuote();

Or

$quote = Mage::getModel('sales/quote')->load(quote_id);

To see items:

$quote->getAllItems()

Remove item:

$quote->removeItem($itemId);
$quote->save();
2
  • only removed if i pass checkout link id/cart/delete/id/19801/, where can i find this ID? Commented Apr 13, 2022 at 19:34
  • ok, so get this id with, $quote->getitemId(); Commented Apr 13, 2022 at 23:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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