How to programmatically retrieve section ids for cart rendering in any theme?

How to programmatically retrieve section ids for cart rendering in any theme?

LucasMRC
Shopify Partner
3 0 1

We're developing a Shopify App that implements the add to cart functionality from the Ajax API.

Is there a way that we can programatically get the required section ids from the theme so that we can make a bundled rendering of the cart, regardless of the theme being used?

 

const formData = new FormData()

formData.append('id', variantId)
formData.append('quantity', quantity)
formData.append('utf8', '✓')
formData.append('form_type', 'product')
formData.append('sections', sections) // ← This is the value we are missing

await fetch(`/cart/add`, {
    method: 'POST',
    headers: {
         'x-requested-with': 'XMLHttpRequest',
         accept: 'application/javascript',
         'Content-Type': 'multipart/form-data',
    },
    body: JSON.stringify(formData)
});

 

Reply 1 (1)

danny_boris
Shopify Partner
10 0 2

@LucasMRC Have you found a solution for this?