When I select a product of specific color of a configurable product and add it to cart, In cart pop up Two products are displayed one indicating the color and the other is simply the product name with image. I need to display exactly the selected color product in the cart pop up. Kindly someone help me to do this.

This is my code to display selected items 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 $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>  
<?php echo "</li></ul>" ?>  
<?php endforeach; ?>

What should be changed here to display the exactly the configurable product with selected color?


1 Answer 1


Try this

$quote = Mage::getSingleton('checkout/session')->getQuote();
$cartItems = $quote->getAllVisibleItems();
foreach ($cartItems as $item) {

  $options = $item->getProduct()->getTypeInstance(true)->getOrderOptions($item->getProduct());
  //Do something

  • I tried your code. The Page is showing error.
    – Ramya
    Jan 15, 2016 at 9:16
  • I have updated my answer Jan 15, 2016 at 9:20
  • should I wrap my code inside this for loop?
    – Ramya
    Jan 15, 2016 at 9:25
  • Yes, You can put your suitable code instead of Do something Jan 15, 2016 at 9:27
  • Hey thank you thank you soo much. I got It. But as In my screen shot above, Now am getting Product name displayed. I just wanted to display the product name with selected color. How to display that.
    – Ramya
    Jan 15, 2016 at 9:33

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.