Thursday, 27 March 2014

How to set minimum quantity in magento cart?

Go to app\design\frontend\base\default\template\checkout\onepage\link.phtml


Put this code in this page


<?php if ($this->isPossibleOnepageCheckout()):?>
<?php if(Mage::helper('checkout/cart')->getCart()->getItemsQty() >= 3):?>
    <button type="button" title="<?php echo $this->__('Proceed to Checkout') ?>" class="button btn-proceed-checkout btn-checkout<?php if ($this->isDisabled()):?> no-checkout<?php endif; ?>"<?php if ($this->isDisabled()):?> disabled="disabled"<?php endif; ?> onclick="window.location='<?php echo $this->getCheckoutUrl() ?>';"><span><span><?php echo $this->__('Proceed to Checkout') ?></span></span></button>
<?php else:?>
<font style="color:red;">You must order a quantity of 3 or more to proceed.</font>
<?php endif?>
<?php endif?>


Then put this code into header.phtml page

<input type="hidden" id="get_cart" value="<?php echo Mage::helper('checkout/cart')->getCart()->getItemsQty(); ?>" />
<script type='text/javascript'>
        jQuery(document).ready(function() {
if(document.getElementById("get_cart").value < 3) {
jQuery(".top-link-checkout").attr("href", "javascript:void(0);")
}
        });

</script>

Then enjoy!!!!!!!!!!!!!!

1 comment:

  1. Great ..if that 3(hardcoded value) can come from some admin setting then this will much better solution...anyway good job..keep it up

    ReplyDelete

Thanks for your comments.