What's your biggest current challenge? Have your say in Community Polls along the right column.

Debut theme ; default variant always used in cart

Solved

Debut theme ; default variant always used in cart

savonsmy
Visitor
2 1 0

Hello!

I'm not sure what I did but since a few days ago I can no longer use any product variants, the default one is always selected.

https://savonsmy.com/products/bombe-de-bain-effervescente

the first one "Ananas-Mangue" will end up in the cart even if you select anything else.

 

From what I can see the theme code looks fine, but when the user selects another variant, the property selected="selected" does not change...

 

I can see the following errors in the JS console but I have no clue what they mean or how to fix it...

 

theme.js?v=20177681164921879581617110627:8008 Uncaught TypeError: Cannot read properties of null (reading 'innerHTML')
    at new t (theme.js?v=20177681164921879581617110627:8008:50)
    at theme.Sections._createInstance (theme.js?v=20177681164921879581617110627:47:34)
    at theme.Sections.<anonymous> (theme.js?v=20177681164921879581617110627:141:14)
    at NodeList.forEach (<anonymous>)
    at theme.Sections.register (theme.js?v=20177681164921879581617110627:139:69)
    at HTMLDocument.<anonymous> (theme.js?v=20177681164921879581617110627:9536:12)

Whichs routes to

this.cartRoutes = JSON.parse(
      document.querySelector('[data-cart-routes]').innerHTML
    );

And this...

TypeError: Cannot read properties of undefined (reading 'includes')
    at Ef.j (m=IZT63,ZyYHPb,ws9Tlc,vfuNJf,PrPYRd,hc6Ubd,Das5Le:231:447)
    at Gf (m=_b,_tp,_r:88:266)
    at If.next (m=_b,_tp,_r:89:91)
    at m=_b,_tp,_r:89:485
    at new Promise (<anonymous>)
    at Jf (m=_b,_tp,_r:89:378)
    at _.Kf (m=_b,_tp,_r:89:520)
    at K0 (m=IZT63,ZyYHPb,ws9Tlc,vfuNJf,PrPYRd,hc6Ubd,Das5Le:230:503)
    at Ef.j (m=IZT63,ZyYHPb,ws9Tlc,vfuNJf,PrPYRd,hc6Ubd,Das5Le:230:276)
    at Gf (m=_b,_tp,_r:88:266)

The theme used is Debut.

 

Any help would be greatly appreciated!

Accepted Solution (1)

savonsmy
Visitor
2 1 0

This is an accepted solution.

Alright so I managed to solve the problem by adding the following javascript code inside theme.liquid file... No clue how it was working before and why it stopped working....

<script type="application/json" data-cart-routes>
      {
        "cartUrl": "{{ routes.cart_url }}",
        "cartAddUrl": "{{ routes.cart_add_url }}",
        "cartChangeUrl": "{{ routes.cart_change_url }}"
      }
  </script>

View solution in original post

Reply 1 (1)

savonsmy
Visitor
2 1 0

This is an accepted solution.

Alright so I managed to solve the problem by adding the following javascript code inside theme.liquid file... No clue how it was working before and why it stopped working....

<script type="application/json" data-cart-routes>
      {
        "cartUrl": "{{ routes.cart_url }}",
        "cartAddUrl": "{{ routes.cart_add_url }}",
        "cartChangeUrl": "{{ routes.cart_change_url }}"
      }
  </script>