Step 1 – Copy the Snippet code below.
<!-- Spice Product Addons Snippet(cart page) Starts -->
<div id="spiceaddonsappid">
{% assign pcollections = '' | split: '' %}{% for item in cart.items %}{% assign product_collections = item.product.collections | map: "id" %}{% if product_collections %}{% assign pcollections= pcollections | concat: product_collections%}{% endif%}{% endfor %}<input type="hidden" id="sgcollectionscart" value="{{ pcollections | uniq | join: "," }}"/>
</div>
<!-- Spice Product Addons Snippet(cart page) ends -->
Step 2 – Go to Online Store under the Shopify admin.
Step 3 – Select Actions (Current theme) and click “Edit code”.

Step 4 – Find the file cart.liquid in the templates folder.

Step 5 – In the cart.liquid file search for the included file name {% section ‘cart-template’%} in the ‘Sections’ folder.
In our theme, the file name is “cart-template“. It may vary depending upon the theme.
Step 6 – Find the <form> and </form> tags in the cart-template.liquid file and paste the snippet above </form> tag.

*For free