Pages

Monday 15 December 2014

Magento:: Minicart on right sidebar


1- First Create a copy of orignal minicart as follow inside the same folder and rename or change the classes
<?php if ($this->getIsNeedToDisplaySideBar()):?>

<div class="sidebar_cart">

<?php

$cart_text='Cart';    

$_cartQty = $this->getSummaryCount() ?>

<div class="block-content_pan">

<div class="summary">

<span class="f-left cart-icon"><i class="fa fa-shopping-cart"></i></span>

<h2 class="classy f-left"><span class="my-cart"><?php echo $this->__('My Cart')?></span>

<?php /*<?php if ($_cartQty==0): ?>

<?php echo $this->__('<a href="%s">0</a><span class="Itext"> %s</span>', $this->getUrl('checkout/cart'), $this->__('item')) ?>

<?php endif ?>

<?php if ($_cartQty>0): ?>

<?php if ($_cartQty==1): ?>

<?php echo $this->__('<a href="%s">1</a><span class="Itext"> %s</span>', $this->getUrl('checkout/cart'), $this->__('item')) ?>

<?php else: ?>

<?php echo $this->__('<a href="%s">%s</a><span class="Itext"> %s</span>', $this->getUrl('checkout/cart'), $_cartQty, $this->__('items')) ?>

<?php endif ?>

<?php endif ?>

*/ ?>

<?php

$count = $this->helper('checkout/cart')->getSummaryCount();  //get total items in cart



if($count==0)

{

echo $this->__('<span class="Itext">0 item</span>',$count)  ;

}

if($count==1)

{

echo $this->__('<span class="Itext">1 item</span>',$count);

}

if($count>1)

{

echo $this->__('<span class="Itext">%s items</span>',$count);

}

?>

</h2>

<!--<em class="bag f-right"><i class="fa fa-angle-down"></i></em>-->

</div>



<div class="remain_cart" id="sidecart" style="display: none;">

<div class="sidecartInner">

<?php if($_cartQty && $this->isPossibleOnepageCheckout()): ?>



<?php endif ?>

<?php $_items = $this->getRecentItems() ?>

<?php if(count($_items)): ?>

<div class="shopping-bag f-block">

<?php if ($_cartQty==1): ?>    

<p class="empty f-left"><?php echo $this->__('Shopping Bag (1 items)') ?></p>

<?php else:?>

<p class="empty f-left"><?php echo $this->__('Shopping Bag (%s items)',$_cartQty) ?></p>

<?php endif?>

<p class="subtotal f-right">

<?php if ($this->canApplyMsrp()): ?>

<span class="map-cart-sidebar-total"><?php echo $this->__('ORDER TOTAL WILL BE DISPLAYED BEFORE YOU SUBMIT THE ORDER');?></span>

<?php else: ?>

<span class="label"><?php echo $this->__('Total:') ?></span> <?php echo Mage::helper('checkout')->formatPrice($this->getSubtotal()) ?>

<?php if ($_subtotalInclTax = $this->getSubtotalInclTax()): ?>

<br />(<?php echo Mage::helper('checkout')->formatPrice($_subtotalInclTax) ?> <?php echo Mage::helper('tax')->getIncExcText(true) ?>)

<?php endif; ?>

<?php endif; ?>

</p>

</div>

<ol id="cart-sidebar" class="mini-products-list">

<?php foreach($_items as $_item): ?>

<?php echo $this->getItemHtml($_item) ?>

<?php endforeach; ?>

</ol>

<script type="text/javascript">decorateList('cart-sidebar', 'none-recursive')</script>

<div class="actions_checkout">

<?php echo $this->getChildHtml('extra_actions') ?>

<button type="button" title="<?php echo $this->__('View Cart') ?>" class="button" onclick="setLocation('<?php echo $this->getUrl('checkout/cart')?>')"><span><span><?php echo $this->__('View Cart') ?></span></span></button>

<button type="button" title="<?php echo $this->__('Checkout') ?>" class="button" onclick="setLocation('<?php echo $this->getCheckoutUrl() ?>')"><span><span><?php echo $this->__('Checkout') ?></span></span></button>

</div>

<?php else: ?>

<div class="shopping-bag f-block"><p class="empty"><?php echo $this->__('You have no items in your shopping cart.') ?></p></div>

<?php endif ?>

</div>

</div>

</div>

</div>

<?php endif;?>

<script type="text/javascript">

jQuery(document).ready(function() {

jQuery(function() {

jQuery(".sidebar_cart").hover(function() {

jQuery(this).addClass('active');

jQuery("#sidecart").stop(true, true).delay(300).slideDown(200, "easeInSine");

},  

function() {

jQuery("#sidecart").stop(true, true).delay(300).fadeOut(100, "easeInCubic");

});



});

});

</script>
2- open the checkout.xml and copy the following block
<block type="checkout/cart_sidebar" name="cart_header" template="checkout/cart/sidebar_header.phtml" after="-">

<action method="addItemRender">

<type>simple</type>

<block>checkout/cart_item_renderer</block>

<template>checkout/cart/sidebar/default.phtml</template>

</action>

<action method="addItemRender">

<type>grouped</type>

<block>checkout/cart_item_renderer_grouped</block>

<template>checkout/cart/sidebar/default.phtml</template>

</action>

<action method="addItemRender">

<type>configurable</type>

<block>checkout/cart_item_renderer_configurable</block>

<template>checkout/cart/sidebar/default.phtml</template>

</action>

<block type="core/text_list" name="cart_sidebar.extra_actions" as="extra_actions" translate="label" module="checkout">

<label>Shopping Cart Sidebar Extra Actions</label>

</block>

</block>
3-Make the following cahanges as follow: and paste it in page.xml inside the block as follow:
<block type="page/html_header" name="header" as="header">

<!--            custom code for minicart                    -->

<block type="checkout/cart_sidebar" name="cart_header" template="checkout/cart/sidebar_cart.phtml" as="sidecart">

<action method="addItemRender">

<type>simple</type>

<block>checkout/cart_item_renderer</block>

<template>checkout/cart/sidebar/default.phtml</template>

</action>

<action method="addItemRender">

<type>grouped</type>

<block>checkout/cart_item_renderer_grouped</block>

<template>checkout/cart/sidebar/default.phtml</template>

</action>

<action method="addItemRender">

<type>configurable</type>

<block>checkout/cart_item_renderer_configurable</block>

<template>checkout/cart/sidebar/default.phtml</template>

</action>

<block type="core/text_list" name="cart_sidebar.extra_actions" as="extra_actions" translate="label" module="checkout">

<label>Shopping Cart Sidebar Extra Actions</label>

</block>

</block>

<!--            custom code for minicart end -->
4-After that call it in header.phtml as follow:
<?php echo $this->getChildHtml('sidecart'); ?>
An example screen of look::

No comments:

Post a Comment