0
<?php
$count = $this->helper('checkout/cart')->getSummaryCount();  //get total items in cart
$total = $count > 0 ?  Mage::helper('core')->currency($this->helper('checkout/cart')->getQuote()->getGrandTotal(), true, false) : '$0.00';
$cartUrl = $count > 0 ? Mage::helper('checkout/cart')->getCartUrl() : "#";
$quote = Mage::getSingleton('checkout/session')->getQuote();
$cartItems = $quote->getAllVisibleItems();
?>
<a href="<?php echo $cartUrl ?>" class="dropdown-toggle" data-toggle="dropdown"><span>Cart</span> (<?php echo $count ?>) <?php echo $total ?> <b class="caret"></b></a>
<?php if(!empty($cartItems)): ?>
<ul class="dropdown-menu" id="cart-dropdown">
<?php foreach ($cartItems as $item): ?>
    <li>
        <div class="cart-item-link">
            <div class="item-cart-content clearfix">
                <div class="item-cart-image">
                    <img src="<?php echo $this->getSkinUrl('images/item-cart.png') ?>" class="img-responsive center-block">
                </div>
                <div class="item-cart-text">
                    <h4 class="item-cart-title"><?php echo $item->getName() ?></h4>
                    <p><?php echo $item->getQty(); ?> x <?php echo Mage::helper('core')->currency($item->getPrice(), true, false) ?></p>
                    <a href="<?php echo $this->getUrl('checkout/cart/delete', array('id' => $item->getId() )); ?>"><?php echo $this->__('Remove Item') ?></a>
                </div>
                <div class="clearfix"></div>
            </div>
        </div>
    </li>
<?php endforeach; ?>    
    <li>
        <div class="cart-subtotal-link">
            <div class="item-cart-content clearfix">
                <div class="item-cart-image">
                    <h4>Order Subtotal</h4>
                </div>
                <div class="item-cart-text">
                    <span class="item-cart-price"><?php echo $total ?></span>
                </div>
                <div class="clearfix"></div>
            </div>
        </div>
    </li>
    <li>
        <div class="cart-btn-container">
            <h5>FREE GROUND SHIPPING on JUICERS & BLENDERS »</h5>
            <div class="btn-container clearfix">
                <a href="https://www.omegajuicers.com/checkout/cart/"><button class="view-shopping-cart menu-cart-btn">View Shopping Cart</button></a>
                <a href="https://www.omegajuicers.com/checkout/onepage/"><button class="checkout-cart menu-cart-btn">Checkout</button></a>
            </div>
        </div>
    </li>
</ul>
<?php endif; ?>

This is my code. The problem I am having is that I am trying to pull an image from the product that has been added to cart. Here it is just pulling one specific image on my server. How can I make it dynamic?

0

Replace your code

<img src="<?php echo $this->getSkinUrl('images/item-cart.png') ?>" class="img-responsive center-block">

With

<img src="<?php echo Mage::helper('catalog/image')->init($item->getProduct(), 'image')->resize(135,135); ?>" class="img-responsive center-block">

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.