Display slide cart on onclick of shopping cart link in header in Magento

First add following code in head.phtml at last.

<script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js”&gt;
</script>

<script type=”text/javascript”>

jQuery.noConflict();

var c = jQuery ;
c(document).ready(function(){

c(‘.ma-shoppingcart’).click(function(){

c(‘.ma-topcart’).slideToggle();
});

});

</script>

Now add following code in page/html/header.phtml

<? $base_url=Mage::getUrl()?>
<?php
$count = $this->helper(‘checkout/cart’)->getSummaryCount(); //get total items in cart
$total = $this->helper(‘checkout/cart’)->getQuote()->getGrandTotal(); //get total price
//if(!$count){$count=0;}
if($count){$items= $count;}else{$items=0;}
$total=number_format($total, 2);
?>

<div class=”ma-shoppingcart” id=”ma-shoppingcart”>
<div class=”cart-item”>Shopping Cart</div>
<span class=”ma-inactive”><?php
if($items > 1){echo ” (“.$items. ” Items)”;}
else if ($items == 1){echo ” (“.$items. ” Item)”;}
else {echo ” (0 Item)”;}
?></span>
</div>

<div class=”ma-topcart” style=”display: none;” id=”ma-topcart”>
<?php echo $this->getLayout()->createBlock(‘checkout/cart_sidebar’)->setTemplate(‘checkout/cart/sidebar.phtml’)->toHtml(); ?>
</div>

Now add following css code into ma-easycart.css  which is created in skin\frontend\default\default\css path.

.ma-topcart {
    background-attachment: scroll;
    background-clip: border-box;
    background-color: #FFFFFF;
    background-image: none;
    background-origin: padding-box;
    background-position: 0 0;
    background-repeat: repeat;
    background-size: auto auto;
    margin-bottom: 0;
    margin-left: 30px;
    margin-right: 0;
    margin-top: -10px;
    padding-bottom: 10px;
    padding-left: 10px;
    padding-right: 10px;
    padding-top: 15px;
    position: absolute;
    text-align: left;
    width: 220px;
    z-index: 990;
}
.ma-topcart .mini-products-list .product-details {
    margin-left: 65px;
}
.ma-topcart .mini-products-list .product-image {
    -moz-border-bottom-colors: none;
    -moz-border-image: none;
    -moz-border-left-colors: none;
    -moz-border-right-colors: none;
    -moz-border-top-colors: none;
    border-bottom-color: #EFEFEF;
    border-bottom-style: solid;
    border-bottom-width: 1px;
    border-left-color-ltr-source: physical;
    border-left-color-rtl-source: physical;
    border-left-color-value: #EFEFEF;
    border-left-style-ltr-source: physical;
    border-left-style-rtl-source: physical;
    border-left-style-value: solid;
    border-left-width-ltr-source: physical;
    border-left-width-rtl-source: physical;
    border-left-width-value: 1px;
    border-right-color-ltr-source: physical;
    border-right-color-rtl-source: physical;
    border-right-color-value: #EFEFEF;
    border-right-style-ltr-source: physical;
    border-right-style-rtl-source: physical;
    border-right-style-value: solid;
    border-right-width-ltr-source: physical;
    border-right-width-rtl-source: physical;
    border-right-width-value: 1px;
    border-top-color: #EFEFEF;
    border-top-style: solid;
    border-top-width: 1px;
}
.ma-topcart a.details {
    font-size: 11px;
}
.ma-topcart .btn-remove, .ma-topcart .btn-edit {
    float: right;
}
.ma-topcart .btn-remove, .ma-topcart .block .btn-edit {
    margin-bottom: 2px;
    margin-left: 5px;
    margin-right: 0;
    margin-top: 1px;
}
.ma-topcart .product-name a {
    font-size: 12px;
}
.ma-topcart li {
    border-bottom-color: #FFFFFF;
    border-bottom-style: solid;
    border-bottom-width: 1px;
    padding-bottom: 7px;
    padding-left: 0;
    padding-right: 0;
    padding-top: 7px;
}
.ma-topcart .summary {
    margin-top: 5px;
}
.ma-topcart {
    display: none;
}
.ma-shoppingcart {
    background-attachment: scroll;
    background-clip: border-box;
    background-color: #FFFFFF;
    background-image: none;
    background-origin: padding-box;
    background-position: 0 0;
    background-repeat: repeat;
    background-size: auto auto;
    color: #5C991F;
    font-weight: bold;
    margin-bottom: 0;
    margin-left: 30px;
    margin-right: 0;
    margin-top: -55px;
    padding-bottom: 0;
    padding-left: 12px;
    padding-right: 12px;
    padding-top: 5px;
    position: absolute;
    z-index: 900;
}
.ma-shoppingcart span:hover {
    cursor: pointer;
}
.ma-shoppingcart .ma-inactive {
    background-attachment: scroll;
    background-clip: border-box;
    background-color: transparent;
   /* background-image: url("../images/down.png");  */
    background-origin: padding-box;
    background-position: 100% 60%;
    background-repeat: no-repeat;
    background-size: auto auto;
}
.ma-shoppingcart span {
    font-size: 18px;
    padding-right: 30px;
}
.ma-shoppingcart .ma-active {
    background-attachment: scroll;
    background-clip: border-box;
    background-color: transparent;
    background-image: url("../images/up.png");
    background-origin: padding-box;
    background-position: 100% 60%;
    background-repeat: no-repeat;
    background-size: auto auto;
}
.ma-shoppingcart .cart-item {
    background-attachment: scroll;
    background-clip: border-box;
    background-color: transparent;
    background-image: url("../images/cart.png");
    background-origin: padding-box;
    background-position: 0 0;
    background-repeat: no-repeat;
    background-size: auto auto;
    padding-left: 28px;
}

Now add following code in page.xml just after <action method=”addCss”><stylesheet>css/styles.css</stylesheet></action>

<action method=”addCss”><stylesheet>css/ma-easycart.css</stylesheet></action>

Thats it…!!!

Advertisements
    • Krite
    • November 8th, 2013

    How to convert to ajax . Thank you very much.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: