Liquid, JavaScript, themes, sales channels
Hey,
I have 2 products of the same thing. one used with 2 images (1 picture and one gif) for the hover effect
and another one used with one image only (for another purpose on the home page)
(if its possible) I want to code an if statement that if a customer adds two of the same product then the cart knows its the same product so it doesn't add twice of the same.
can someone help me with the code and where specifically to add it?
Solved! Go to the solution
This is an accepted solution.
Hi @bakyboy
Sorry for making you wait.
It's Done.
In the featured-product.liquid file, the product-form.liquid is included and all changes are made there. We put the check on the main page and added the class.
Can you check it please?
Hi @bakyboy
Aibek is here from Speedimize.io
Welcome to Shopify Community.
Create only one product and add two images. One of them is normal, and the other is a gif. And this will be the default product that will be shown for the product page. On the main page you will use the same product, only you need to put a check
{% if template == "index" %}
//Home page product
{% endif %}
If there is a {% for%} loop, then you will need to put {% break %} on the first pass. That is, put it at the end. For example as below:
{% for image in product.images %}
<li class="grid__item {{ product_thumbnail_width }} product-single__thumbnails-item">
<a
href="{{ image.src | img_url: product_image_size, scale: product_image_scale }}"
class="text-link product-single__thumbnail product-single__thumbnail--{{ section.id }}"
{% if enable_zoom %}data-zoom="{{ image.src | img_url: product_image_zoom_size, scale: product_image_scale }}"{% endif %}>
<img class="product-single__thumbnail-image" src="{{ image.src | img_url: product_thumb_size, scale: product_image_scale }}" alt="{{ image.alt | escape }}">
</a>
</li>
{% if template == 'index' %}
{% break %}
{% endif %}
{% endfor %}
We don't know which is your theme and structure of it. Therefore, the above example is from the debut theme. Most likely, the section on your main page is called featured-product. liquid. All changes will need to be made in this file. In the example above, the loop will only run once and only one image will be shown. This is the simplest logic for solving your problem.
Hey, im using the showcase theme
and for some reason I can't seem to find the right section to copy this code to
please help
Hey @bakyboy
Thanks for getting back to me.
Sorry for the delayed response due to the weekend.
Can you please give us a staff account or grant access through Shopify partners?
Showcase is not a free theme, so we can't help you without this.
Hope for your cooperation.
Hey, what email should I sent the staff invite to?
I sent the invite to this mail hello@speedimize.io
yes, do I did
Can you please send me the URL of your shop?
I think it's will be better to use Shopify Partners.
Request is sent.
approved
Hey, have you looked at it? done anything?
This is an accepted solution.
Hi @bakyboy
Sorry for making you wait.
It's Done.
In the featured-product.liquid file, the product-form.liquid is included and all changes are made there. We put the check on the main page and added the class.
Can you check it please?
hey I was a bit off these days, thank you very much! looks great
appreciate it
Are you ready to take your business to the next level? Look no further than the latest ...
By SarahF_Shopify Apr 15, 2024We’re keeping the ball rolling to make sure you’re always ahead of the game. So buckle ...
By JasonH Apr 8, 2024Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024