0

Can any one please help me to load magento cart block into a drop down box. To be more specific, the module title or a menu should display some thing like 'my basket' and there should be a message of number of items in the cart below 'my basket'. When the user hovers the menu the drop down box should display the content of the cart/sidebar.phtml.Can anyone please suggest me how I can achieve this?

Thanks in advance.

Nazeehaa
  • 5
  • 2
  • 5

2 Answers2

0

I am doing this for a site I am working on. Unfortunately, I have had to do this through a static block...but it seemed to work without any issues. This is working for me, have a play and see how you go.

The CSS is pretty simple and is they key to showing and hiding the drop down itself.

CSS

// this is the panel where the cart is displayed
DIV#cart-panel {
    width:100px; //arbitary width
    position:absolute; // need this so that it doesn't interfere with the layout
    display:none; // hides the block
    z-index:200; // makes it way it in front of other content
}

#cartBtn:hover #cart-panel { display: block; } // basically, when you hover over the cartBtn, the cart-panel displays

Static Block contains

<li id="myCartBtn">
    <a href="{{store url=checkout/cart}}" rel="cart">My Cart</a>
    {{block type="checkout/cart_sidebar" template="checkout/cart/sidebar.phtml"}}
</li>

Then in my sidebar.phtml, I just make sure there is a div with id="cart-panel" in it, surrounding the cart itself, instead of the <div class="block block-cart">

<?php if ($this->getIsNeedToDisplaySideBar()): ?>
<div id="cart-panel">
...
</div>
<?php endif; ?>

Then, finally, I put the static block into the template where I need it

CCBlackburn
  • 1,704
  • 1
  • 12
  • 23
  • Hi thanks for your answer, I will try this solution and let you know how it goes. – Nazeehaa Apr 14 '12 at 13:36
  • Hi CCBlackburn, I could get the cart link only in my page but the dropdown thing is not working. There is no dropdown box displayed for the mouse hover. I have exactly done the same thing you suggested. Do you have any idea like where the issue can be? – Nazeehaa Apr 14 '12 at 19:03
  • The only thing I can think of is that `($this->getIsNeedToDisplaySideBar())` is returning false...check that you have it enabled in the config area. In Admin go to Configuration -> Sales -> Checkout -> Shopping Cart Sidebar and make sure "Display Shopping Cart Sidebar" is set to Yes – CCBlackburn Apr 15 '12 at 03:38
0

check Fatdivision AJAX Quick Cart article.

Oğuz Çelikdemir
  • 4,990
  • 4
  • 30
  • 56
  • Hi Oguz, I already went through this article but came up with some JS errors that I could not fix at all. That's why I'm looking for some other solution. – Nazeehaa Apr 14 '12 at 13:38