if you want to display a dropdown list of products in my cart on MouseOver on 'My Cart' in top menu then follow these easy step:
1.copy the following line of code and save this in file cartlist.phtml at path
app\design\frontend\base\default\template\catalog\product\
code:
////////////
//////////////
2. add this xml code in catalog.xml in default scope
app\design\frontend\base\default\layout\
////////////
///////////////////
3. find the following line of code in
app\code\core\Mage\Checkout\Block\ Links.php
//////////////
/////////////
and replace with
///////////
that's it.
Enjoy!!!.....
1.copy the following line of code and save this in file cartlist.phtml at path
app\design\frontend\base\default\template\catalog\product\
code:
////////////
<?php if(Mage::helper('checkout/cart')->getSummaryCount()>0) { ?>
<div style="display:none;position: relative;left: 650px;width: 200px;top: -70px;" id="vinod">
<div class="block block-cart">
<div class="block-title">
<strong><span><?php echo $this->__('My Cart') ?></span></strong>
</div>
<div class="block-content">
<?php
$cartid= Mage::getModel('checkout/cart')->getProductIds();
foreach($cartid as $pid)
{
$pname= Mage::getModel('catalog/product')->load($pid)->getName();
?>
<p><b><?=$pid?>=<?=$pname?></b></p>
<?php
}
?>
</div>
</div>
</div>
<? }?>
//////////////
2. add this xml code in catalog.xml in default scope
app\design\frontend\base\default\layout\
////////////
<reference name="content">
<block type="catalog/product" name="catalog.product.cartlist" template="catalog/product/cartlist.phtml"/>
</reference>
///////////////////
3. find the following line of code in
app\code\core\Mage\Checkout\Block\ Links.php
//////////////
public function addCartLink()
{
$parentBlock = $this->getParentBlock();
if ($parentBlock && Mage::helper('core')->isModuleOutputEnabled('Mage_Checkout')) {
$count = $this->getSummaryQty() ? $this->getSummaryQty()
: $this->helper('checkout/cart')->getSummaryCount();
if ($count == 1) {
$text = $this->__('My Cart (%s item)', $count);
} elseif ($count > 0) {
$text = $this->__('My Cart (%s items)', $count);
} else {
$text = $this->__('My Cart');
}
$parentBlock->removeLinkByUrl($this->getUrl('checkout/cart'));
$parentBlock->addLink($text, 'checkout/cart', $text, true, array(), 50, null, 'class="top-link-cart"');
}
return $this;
}/////////////
and replace with
///////////
public function addCartLink()
{
$parentBlock = $this->getParentBlock();
if ($parentBlock && Mage::helper('core')->isModuleOutputEnabled('Mage_Checkout')) {
$count = $this->getSummaryQty() ? $this->getSummaryQty()
: $this->helper('checkout/cart')->getSummaryCount();
if ($count == 1) {
$text = $this->__('My Cart (%s item)', $count);
} elseif ($count > 0) {
$text = $this->__('My Cart (%s items)', $count);
} else {
$text = $this->__('My Cart');
}
$parentBlock->removeLinkByUrl($this->getUrl('checkout/cart'));
$parentBlock->addLink($text, 'checkout/cart', $text, true, array(), 50, null, 'class="top-link-cart" onMouseOver="$(\'vinod\').toggle();"');
}
return $this;
}
/////////that's it.
Enjoy!!!.....
Hello vinod,
ReplyDeleteIts not working.
Venkat
It is working Venkat.....it may be jquery conflict or jquery not include problem...just chekout the source code of html page that div is coming or not..
DeleteReally Nice script Vinod , I was looking for it.
ReplyDeleteThanks
I'm not sure what I have done wrong. But the div is there. My cart however doesn't toggle on mouse over. When I checkout the source code there is no error whatsoever.
ReplyDeleteAny idea? I'm using magento CE 1.6.2.
Thank you
Hi Han K. Hee,
Deletecan you provide me the url where you are using this code ?
Hi Vinod,
DeleteThanks for your reply.
However, while I was waiting for your reply, I return the files to their original condition in the meantime.
I applied back to your files setting now.
You can take a look at my project site at : www.kollap.com
I wanted it to work like the login box beside my cart link.(only difference will be that login box is onclick not on hover)
Hi Han K. Hee,
DeleteAs I can see in your project you did not include catalog/product/cartlist.phtml file in the content part i.e. there is some mistake in first 1 & 2 step of my given solution.
If you want to show cart item on click then please change the line $parentBlock->addLink($text, 'checkout/cart', $text, true, array(), 50, null, 'class="top-link-cart" onMouseOver="$(\'vinod\').toggle();"'); to the $parentBlock->addLink($text, 'checkout/cart', $text, true, array(), 50, null, 'class="top-link-cart" onClick="$(\'#vinod\').toggle();"');
I think this will help you .....
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeletehi vinod,
ReplyDeleteit's working fine but when mouseover the page is flickering why?
Thanks for your comment. Can you please check the jquery conflict and CSS property of the drop down cart block. I think the CSS property of block may cause of this.
DeleteThis code support for magento 1.9.0.1
ReplyDeleteI didn't try with this version. You can try, I hope it will work.
DeleteThanks