I looked at default/template/checkout/cart.html and found this code:
getItems() as $_item): ?>
It seems that these are the questions, which I asked again & again (some 14 months back). Some basics need to be cleared now.
In Checkout Cart, the main entity is the "Quote" (whose class is "Mage_Sales_Model_Quote
") and it is not at all related to the "Catalog Product" entity (whose class is "Mage_Catalog_Model_Product
"). So, products have their own unique (numeric) IDs, but when they get added to the Shopping Cart, their IDs are no more relevant in the Shopping Cart page (except for the Product URL, since the user may want to view the Product details page again).
In the Checkout Cart page, the IDs available are specifically the Quote Item IDs for each of the items added there, and the Checkout Cart itself has a Quote ID, which is the parent of all the items added to the Cart during that particular Checkout Session.
This Quote details can be found in the database table "sales_flat_quote
", and its items can be found in "sales_flat_quote_items
".
Now coming back to the question, the view page which you are seeing is "default/template/checkout/cart.phtml
" (There is no page with extension "html
", it should be "phtml
"). This is the view page of the whole Cart. Since you are interested in the items, so you should be looking at "default/template/checkout/cart/item/default.phtml
". The Block class, which it refers to, is "Mage_Checkout_Block_Cart_Item_Renderer
". This PHTML page serves for each item, so whatever you need to do for each item can be done in this page.
To remove the Product from the Cart, you need to know that product's Quote Item ID, and write the following statement:-
$this->getUrl('checkout/cart/delete', array('id' => 'xxxx'));
where xxxx
refers to the to-be-deleted product's Quote Item ID.
To remove the Product from the Cart, in the Checkout Cart page, you need to call the following statement in "default/template/checkout/cart/item/default.phtml
":-
$this->getDeleteUrl();
When this statement will get executed, it will take in that product's Quote Item ID from internal automatically (that's the beauty of Magento).
To get the Product ID from the Cart, in the Checkout Cart page, you need to call the following statement in "default/template/checkout/cart/item/default.phtml
":-
$this->getProduct()->getId();
The method "getProduct()
" will return & load that Product's Model object (with all the details), which the next method "getId()
" will use it for fetching that Product's ID.
Hope it helps.