Redirect Support for Line Item Properties

Follow these instructions if your products inside of Shopify can be individually customized. These customization fields are called Line Item Properties.

This document assumes that you have already followed the instructions on this article: Shopify Checkout Redirect - Standard Cart

  • Step 1 - Log into Shopify and navigate to Online Store>Themes

  • Step 2 - Select and edit the theme you want to make changes to

  • Step 3 - Locate the redirect script inside theme code

  • Step 4 - Replace old script with new script


Step 1 - Log into Shopify and navigate to Online Store>Themes

Step 2 - Select and edit the theme you want to make changes to

Step 3 - Locate the redirect script inside theme code

The Redirect Script would have been placed in Step 2 on this article: Shopify Checkout Redirect - Standard Cart

If instructions were followed exactly, the snippet should be called {your-shopify-store-name}-cart.js.liquid

Step 4 - Replace old script with new script

Copy the script below and paste this over the old script

function productIdsWithQuantities() {
    {%- assign added_first = false -%}
    return {
      {%- for item in cart.items -%}
        {%- assign property_size = item.properties | size -%}
        {% if property_size > 0 %}
          {%- capture prdctOptions -%}
            {% for p in item.properties %}
              {% unless p.last == blank %}{{ p.first }}~{% if p.last contains '/uploads/' %}{{ p.last | split: '/' | last }}{% else %}{{ p.last }}{% endif %}{% unless forloop.last %}|{% endunless -%}
              {% endunless %}
            {% endfor %}
          {%- endcapture %}
          {%- assign prdctOptionForUrl = prdctOptions | newline_to_br | split: '<br />' -%}
          {%- capture stripedPrdctOptions -%}
            {% for pOption in prdctOptionForUrl -%}
                {{ pOption | strip | strip_newlines | url_encode  }}
            {%- endfor %}
          {%- endcapture %}
        {% endif %} 
        {%- if item.variant.metafields.productId.productId -%}
      {%- if added_first %},{% endif -%}
        {%- if item.selling_plan_allocation -%}
          {% if property_size > 0 %}
            "{{ item.variant.metafields.productId.productId}}{{"|"}}{{item.selling_plan_allocation.selling_plan.name | url_encode}}{{ "|" }}{{ stripedPrdctOptions | strip_newlines }}": {{ item.quantity | json }}
          {% else %}
            "{{ item.variant.metafields.productId.productId}}{{"|"}}{{item.selling_plan_allocation.selling_plan.name | url_encode}}": {{ item.quantity | json }}
          {% endif %}
      {%- else -%}
          {% if property_size > 0 %}
            "{{ item.variant.metafields.productId.productId }}{{ "|" }}{{ "|" }}{{ stripedPrdctOptions | strip_newlines }}": {{ item.quantity | json }}
          {% else %}
            "{{ item.variant.metafields.productId.productId }}": {{ item.quantity | json }}
          {% endif %}
      {% endif -%}
          {%- assign added_first = true -%}
        
      {%- endif -%}
      
      {%- endfor -%}
    };
  }