FROM CACHE - en_header

Rendering main-cart-footer in a Dawn mini cart

jrob
New Member
1 0 1

I've been building a mini cart on Dawn following this tutorial. https://scratchlabsdigital.com/shopify-2-0-dawn-how-to-mini-cart/

Everything is working well except for the main-cart-footer. The getSectionsToRender function in cart.js selects the main-cart-footer by data-id attribute which is available on the cart page. When the cart api is called bundled section rendering returns the html for the main-cart-footer just fine.

1.jpg2.jpg

When we are not on the cart page there is no dynamic id attribute is available. I have tried using the 'main-cart-footer' which is the static id of the section but the bundled section rendering doesn't return the dynamic content inside of cart__blocks.

3.jpg4.jpg

It's not possible to hard code dynamic id attribute because it changes. I have also tried using the sections_url parameter available set to the context of '/cart' and still get the empty area of the cart.
https://shopify.dev/api/ajax/reference/cart#bundled-section-rendering.

Anyone attempted this before or faced a similar issue?

Reply 1 (1)
scratchlabs
New Member
1 0 0

Step 4 was updated a month or so back

 

Important Note: In order for the footer messaging and price to work in the mini cart, you will need to make sure that the main-cart-footer.liquid includes default settings:

"default": {
    "blocks": [
        {
            "type": "subtotal"
        }, 
        {
            "type": "buttons"
        }
    ] 
}

I think this is why it errors out. The Cart messaging can be a pain too.