Top

HTML Escape Characters Showing up in Cart

If HTML escape characters that were used in product descriptions are showing up on the cart page, follow these steps to replace them:

  1. From "Shopify Admin", select Online Store.

    select online store 

  2. Select Actions.

    Actions 

  3. Select Edit code.

    Edit code 

  4. Under "Templates", select cart.liquid.

    Note: If your theme contains sections, you may need to select cart-template.liquid, under "Sections" instead.

    select cart.liquid 

  5. Find the second p loop; it should look something like this:
    {% if p.last contains '/uploads/' %}
    <a href="{{ p.last }}">{{ p.last | split: '/' | last }}</a>
    {% else %}
    {{ p.last }}
    {% endif %}

    find the code 

  6. Replace the p.last with this code:
    {% capture temp %} {{ p.last | replace: "'", "'"}} {% endcapture %}

    replace p.last with this code 

    The result should look similar to this:

    {% if p.last contains '/uploads/' %}
    <a href="{{ p.last }}">{{ p.last | split: '/' | last }}</a>
    {% else %}
    {% capture temp %} {{ p.last | replace: "'", "'"}} {% endcapture %}
    {% endif %}

    replace the code 

  7. Select Save.

    select save 

Note: This example code uses the HTML escape for an apostrophe, replace that with whatever escape you are trying to replace. If this doesn't work as expected, you may need to expand the code to this:

{% capture temp %} 
{{ p.last | remove: "&"}} 
{% endcapture %}
{% capture temp %} 
{{ temp | remove: "amp;"}} 
{% endcapture %} 
{% capture temp %} 
{{ temp | replace: "'", "'"}} 
{% endcapture %} 
{{ temp }}
<br/>

Next Steps