PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, July 1, 2022

[FIXED] How check if product exist in cart in Shopify

 July 01, 2022     shopify, shopify-app, shopify-template     No comments   

Issue

I want to show recommended products in the cart window.

Below is the code -

{%- if cart.item_count > 0 -%}
  {%- assign product_image_size = '800x1026' -%}
  {% for product in collections[settings.product_upsell_collection].products limit:settings.product_upsell_limit %}
     {%- for item in cart.items -%}
         {%- if item.product.handle != product.handle -%}
             {%- assign product_show = 'no' -%}

             //Other html product markup

         {%- endif -%}
     {% endfor %}
  {% endfor %}       
{%- endif -%}

The issue I'm facing is that the products already in the cart are also showing up in the recommended.


Solution

I'd prefer to:

{%- unless item.product_id == product.id -%}
         //Other html product markup
{%- endunless -%}


Answered By - Juandres Yepes Narvaez
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing