Skip to content

Why does my free-shipping.phtml template only show in my minicart when i’m in checkout/cart page?

I have a custom free-shipping.phtml template which shows the amount remaining until free shipping. I can see it only in my minicart when i’m in checkout/cart page.

I referenced the container with the name=”minicart.addons” from the minicart as can be seen in the code below:

–> Magento_Checkout/layout/default.xml

<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="minicart.addons">
            <block class="MagentoFrameworkViewElementTemplate" name="free-shipping-minicart" before="-" template="Magento_Checkout::cart/free-shipping.phtml"/>
        </referenceContainer>
    </body>
</page>```

Since i was unable to get the corresponding value from the cart from quote.js, i tried to get it from Magento_Customer/js/customer-data.js but still it does not return anything.

I wonder if someone already had the same issue, and if so, i would really appreciate some help.