1

The following is code

$itemsCollection = Mage::getSingleton('checkout/session')->getQuote()->getItemsCollection();

// get array of all items what can be display directly
$itemsVisible = Mage::getSingleton('checkout/session')->getQuote()->getAllVisibleItems();

// retrieve quote items array
$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();

foreach($items as $item) {

    echo '<div class="qc-row qc-row-item">';
    echo '<span class="qc-col-qty">'.$item->getQty().'</span>';
    echo '<span class="qc-col-name"><a href="'.$item->getUrl().'">'.$item->getName().'</a></span>';
    echo '<span class="qc-col-price">'.$item->getPrice().'</span>';
    echo '<span class="qc-col-price">'.$item->getRemoveUrl().'</span>';
    echo '</div>';

}

Everything is fine but '.$item->getUrl().' and '.$item->getRemoveUrl().' are not working. Any help will be appreciated.

3

You cannot get cart item remove url by using $item->getRemoveUrl()and product URL from

Because magento doesn't save remove and product url.

so please try this

cart remove url

$itemRemoveUrl=$this->getUrl('checkout/cart/delete',array('id'=>$item->getId(),
   Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED=>$this->helper('core/url')->getEncodedUrl())
        );

Product Url: By Item product object

 $product = $item->getProduct();
 $productUrl=$product->getUrlModel()->getUrl($product);

Your code

       foreach($items as $item) {

    echo '<div class="qc-row qc-row-item">';
    echo '<span class="qc-col-qty">'.$item->getQty().'</span>';

    $itememoveUrl=$this->getUrl('checkout/cart/delete',array('id'=>$item->getId(),
                Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->helper('core/url')->getEncodedUrl())
        );
 $product = $item->getProduct();
 $productUrl=$product->getUrlModel()->getUrl($product);

    echo '<span class="qc-col-name"><a href="'.$productUrl.'">'.$item->getName().'</a></span>';
    echo '<span class="qc-col-price">'.$item->getPrice().'</span>';
    echo '<span class="qc-col-remove"><a href="'.$itememoveUrl.'"><i class="fa fa-times fa-fw"></i></a></span>';
    echo '</div>';
 }
  • Not working.. Can you update my above given code and paste here so that I can fully copy paste. Will it get repeats even if the customer adds 6 different items? – Shoeb Mirza Apr 8 '15 at 17:10
  • update and it works – Amit Bera Apr 9 '15 at 1:07

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.