How can I display products based on customer tags in Spark theme?

How can I display products based on customer tags in Spark theme?

colinrw
Visitor
2 0 0

Hi everyone,

 

I am currently using the 'Spark' theme. I would like to only show certain products based on customer tags. For example: only show X products if customer tags is 'purchased'. In this example only customers who have made a purchase before should be able to see set products. 

 

I want to create a 'secret' collection that is only visible to the customer who made a purchase. Is it possible to have a collection AND products only visible for certain customers with a specific tag?

 

Thank you 🙂

Replies 2 (2)

NomtechSolution
Astronaut
1245 113 159
  1. Open the theme code editor for the Spark theme and locate the template file responsible for rendering the collection page (typically collection.liquid).

  2. Inside the template file, find the code that retrieves and displays the products for the collection. You'll need to modify this code to include a condition that checks the customer's tags before displaying the products.

  3. Within the code that loops through the products, add a conditional statement to check if the customer has the required tag. You can use the customer.tags object to access the customer's tags.

  4. If the customer has the required tag, display the product; otherwise, skip it.

Here's a sample code snippet that demonstrates the conditional display based on customer tags:

{% for product in collection.products %}
  {% if customer.tags contains 'purchased' %}
    <!-- Code to display the product -->
    <h3>{{ product.title }}</h3>
    <p>{{ product.description }}</p>
    <!-- Add any other product details as needed -->
  {% endif %}
{% endfor %}

magecomp
Shopify Partner
461 31 47

Hello @colinrw 

 

You can follow @NomtechSolution suggestion

or try the app 

https://apps.shopify.com/required-login-for-customersv

Helping voluntarily. Please like and accept the solution if it helps. Thanks!
Our Bestseller Shopify Apps    |      Mobile App Builder by MageComp    |      Shoplock Hide Pages/Collections

Need a developer?  Just visit MageComp website