Magento – Coupon block not displaying inside mini cart

couponcssmagento-2.1mini-cart

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!)

\Magento\Checkout\view\frontend\layout\default.xml

UPDATED: To display the coupon block in the minicart

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

Best Answer

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

module-checkout/view/frontend/web/js/view/minicart.js

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

Hope these are some helpful research track.