1

I just want to remove a single item from the Cart pop up.Here is my code to display the product image, name, Quantity, price and Remove icon in cart pop up.

<?php foreach($items as $_item): ?>
<?php $isVisibleProduct = $_item->getProduct()->isVisibleInSiteVisibility();?>
<?php $product = $_item->getProduct(); ?>
<?php echo "<ul> <li class='item'>"; ?>
<span class="cart-img"><a href="<?php echo $product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($product, 'small_image')->resize(50, 50); ?>" width="50" height="50" alt="<?php echo $this->stripTags($this->getImageLabel($product, 'small_image'), null, true) ?>" /></a></span>
<span class="cart-name"><?php echo $_item->getName();?></span>
<span class="cart-qty"><?php echo $_item->getQty();?></span>
<span class="cart-price"><?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?></span>
<?php $_item = $this->getItem(); 
$url=$this->getUrl('checkout/cart/delete', array('id' => $_item->getProductId())); ?>
<span class="cart_item_delete" ><a href="<?php echo $url ?>" title="<?php echo $this->__('Remove This Item') ?>" onclick="return confirm('<?php echo $this->__('Are you sure you would like to remove this item from the shopping cart?') ?>');" class="btn-remove"><?php echo $this->__('Remove This Item') ?></a></span> 
<?php echo "</li></ul>" ?>  
<?php endforeach; ?>

When I add the product to the cart everything is going blank. When I remove the three lines of code written for removing the item from the cart pop up,everything is displayed perfectly but the remove icon is not working & the product is not getting removed.The page is refreshed and nothing happens.

This is that three lines of code snippet from above code for removing an item from cart pop up:

<?php $_item = $this->getItem();
$url=$this->getUrl('checkout/cart/delete', array('id' => $_item->getProductId())); ?>
<span class="cart_item_delete" ><a href="<?php echo $url ?>" title="<?php echo $this->__('Remove This Item') ?>" onclick="return confirm('<?php echo $this->__('Are you sure you would like to remove this item from the shopping cart?') ?>');" class="btn-remove"><?php echo $this->__('Remove This Item') ?></a></span>

please someone tell me where I went wrong?

1
 <?php $_item = $this->getItem();
    $url=$this->getUrl('checkout/cart/delete',array('id'=>$_item->getId())); ?>
    <span class="cart_item_delete" ><a href="<?php echo $url ?>" title="<?php echo $this->__('Remove This Item') ?>" onclick="return confirm('<?php echo $this->__('Are you sure you would like to remove this item from the shopping cart?') ?>');" class="btn-remove"><?php echo $this->__('Remove This Item') ?></a></span>
  • Thank you.I followed your code. My code is edited above. Kindly see that and give me a solution. – Ramya Jan 9 '16 at 5:53
  • updated the answer kindly check and feedback – Qaisar Satti Jan 9 '16 at 10:07
  • No still it is same. – Ramya Jan 9 '16 at 10:12
  • $_item = $this->getItem(); remove this from ur code – Qaisar Satti Jan 9 '16 at 10:19
  • Even after removing it is still the same – Ramya Jan 9 '16 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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