I have searched a lot on google but didn't get the solution for this. I new to Magento, can any help me to how to add the coupon code section in Mini cart of magento. Like the Below Example: enter image description here

I have added this in items.phtml

<?php $getCouponCode = Mage::getSingleton('checkout/cart')->getQuote()->getCouponCode(); ?>
                    <form id="discount-coupon-form" action="<?php echo $this->getUrl('checkout/onepage/coupon')?>" method="post">
                    <!-- <label for="coupon_code"> <?php //echo $this->__('Enter your coupon code if you have one.') ?></label> -->
                    <input id="coupon_code" name="coupon_code" value="<?php echo $getCouponCode; ?>"/>
                    <?php  if(strlen($getCouponCode)) { ?>
                    <button type="button" onclick="updateminiCoupon(2); return false;" value="<?php echo $this->__('Remove Coupon')?>"><span><?php echo $this->__('Remove Coupon') ?></span></button>
                    <?php } ?>
                    <button type="button" onclick="updateminiCoupon(1); return false;" value="<?php echo $this->__('Apply Coupon')?>"><span><?php echo $this->__('Apply Coupon') ?></span></button>

and js :

<script type="text/javascript">
function updateminiCoupon(reqid) {
    var reqid;
    if(reqid == 2) {  $('coupon_code').setValue('');  }
        method: 'post',
        onComplete: payment.onComplete,
        onSuccess: payment.onSave,
        onFailure: checkout.ajaxFailure.bind(checkout),

by reference link: http://www.endreywalder.com/blog/add-coupon-code-form-to-magento-onepage-checkout-review-step/

Check the Reference site : http://www.nykaa.com/

<?php echo $this->getLayout()->createBlock('checkout/cart_coupon')->setTemplate('checkout/cart/coupon.phtml')->toHtml(); ?>

Please make use the above code and call the same in the file path


Note: i have used the default mangento 1.9.x with rwd theme enter image description here


enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.