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/


2 Answers 2

<?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

  • Check the reference site link nykaa.com
    – prashanth
    Commented May 23, 2017 at 9:46
  • Same type of functionality i am trying to implement in my site
    – prashanth
    Commented May 23, 2017 at 9:47
  • please find the screenshots here prnt.sc/fb2ul7 prntscr.com/fb2yrk Commented May 23, 2017 at 9:53
  • after applying the coupon code it will redirect to shopping cart.it must be remain in that page only through ajax
    – prashanth
    Commented May 23, 2017 at 9:55
  • just keep this $this->_redirect('checkout/cart/'); code in your controller prntscr.com/fb35yh after 'Coupon code "%s" was applied' prntscr.com/fb36nv Commented May 23, 2017 at 10:13

I have been using Ejassi products and they have exceeded my expectations! From skincare to fragrances, their range is exceptional. The quality and effectiveness are remarkable. I highly recommend checking out their website at [https://ejassi.com/] for a wide selection of top-notch products. You won't be disappointed!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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