Issue with /cart/add: Empty section value when boolean in settings_data is true

Hi everyone,

I’m currently working on a theme based on the Dawn theme. I’ve introduced a new setting in the settings_scheme that contains a boolean and a richtext. It’s about a custom message that gets displayed in the cart_drawer, if the setting is set to true. This is the snippet in the cart_drawer.liquid that renders my new snippet:

{%- if settings.cart_show_info -%}
    {% render 'cart-info' %}
{%- endif -%}

The snippet itself works, so if I open the drawer manually, I see my message as expected.

Now I’m facing the issue that, if my new setting is set to “true” (in settings_data) and the element gets rendered in the card_drawer.liquid, calling the “/cart/add” route returns an object that has “sections: null”. That prevents the cart_drawer to open automatically after hitting the “Add to cart” button since the JS function “renderContents()” runs into an error at this point:

sectionElement.innerHTML =
          this.getSectionInnerHTML(parsedState.sections[section.id], section.selector);

The error at this place is that parsedState.sections (= the response from “cart/add”) is null.

Now, I have no clue why the “sections” in the returned object is empty only if my new setting is set to “false” in “settings_data” or I remove my snippet above from the “cart_drawer.liquid”.

Btw: If I replace my snippet in the cart_drawer.liquid with any random HTML snippet (e.g. a paragraph), everything works as expected – it just happens with my snippet.

Looking really forward for your help, thanks a lot in advance! :folded_hands:

Alright, I’ve found the issue myself. During a merge, GitHub or VS Code has somehow placed a hidden character instead of a space which seems to have broken the sections loop from the Dawn script. Replacing that hidden character with an actual space fixed the issue and everything works as expected.