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.
  2. Select ...
  3. Select Edit HTML / CSS.
  4. Under "Templates", select cart.liquid.

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

  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 %}
  6. Replace the p.last with this code:
    {% capture temp %} {{ p.last | replace: "'", "'"}} {% endcapture %}

    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 %}
  7. 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/>
Have more questions? Submit a request