I am trying to add coupon block in mini cart of magento.

But the coupon code block is displaying in the content section (also css changed!)


UPDATED: To display the coupon block in the minicart

 <referenceContainer name="minicart.addons">
        <block class="Magento\Checkout\Block\Cart\Coupon" name="checkout.cart.coupon">
                <argument name="template" xsi:type="string">Magento_Checkout::cart/coupon.phtml</argument>

2 Answers 2


In the xml it's unlikely that a reference to header-wrapper is the one to use. Something could be added in module-checkout/view/frontend/templates/cart/minicart.phtml.

I noticed <?php echo $block->getChildHtml('minicart.addons'); ?> in there, so maybe addons (like coupon) could be added from the back office.

If not then maybe you'll have to search in


or in module-checkout/view/frontend/web/js/discount-codes.js

Hope these are some helpful research track.

  • oh cool buddy, i tried with referenceContainer name="minicart.addons" and it worked :D thanks for the tip, except the 'Apply Discount Code' link doesnt appear as one... like how it appears on the checkout page
    – Sushivam
    May 24, 2017 at 6:02
  • If it is a display issue, then maybe it's due to some css in cart/coupon.phtml , that isn't destined to be in mini-cart area, conflicting there. maybe you can provide some more details, cool !
    – medmek
    May 26, 2017 at 9:20
  • @Sushivam hii! did you find solution for this? if yes please share here. i also want to display coupon code section in minicart. Mar 24, 2021 at 11:47

You Can add this code in minicart.phtml

echo $this->getLayout()->createBlock('Magento\Checkout\Block\Cart\Coupon')->setTemplate('Magento_Checkout::cart/coupon.phtml')->toHtml();

But this has to be outside minicart-content-wrapper "div" else there will be css conflicts and Apply coupon code option won't work.

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.