Reputation: 1164
In product list page how can I get the quantity currently added in the cart.
Just in case if i have 'ottoman' 10 qty in the cart, how can i show the added QTY besides the product name.
Upvotes: 1
Views: 213
Reputation: 7611
add below code start of list.phtml
<?php
$currentCart=array();
//$currentCartItemDetails=array();
$quote = Mage::getSingleton('checkout/session')->getQuote();
foreach ($quote->getAllItems() as $item) {
if ($item->getProductId()) {
$currentCart[$item->getProductId()]=$item->getQty();
}
}?>
after that add below code after isSaleable()): ?>
<?php
if (isset($currentCart) and array_key_exists($_product->getId(), $currentCart)) {
?>
<input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $currentCart[$_product->getId()] ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
<?php }?>
Upvotes: 1