Hey Guys,
i want to sell personalized Smartphone-Cases (“personalisierte Handyhüllen!”) additional to "Erschaffe dein Kunstwerk! → look at the homepage.
I want a rich-text to apply only for the Smartphone Cases and not the other product, how do i do that?
It applies automatically to both products ;/
Does anyone have a solution for that?
Hi,
One way to apply rules to some products in your store and not others is via the use of conditionals.
This will require some basic knowledge of coding, but the way to do it, in your example, is to create a Smartphone Cases Collection for all your smartphone cases, and then add code in your theme to separate the smartphone cases from everything else.
Doing this will allow you to handle the partial application of Rich Text, as well as anything else you may want to add in the future.
I’m not familiar with the theme used in the site, but the conditional would look something like this:
{% for collection in product.collections %}
{% if collection.id == 123456789 %}
Code to apply rich-text...
{% else %}
code to not apply rich-text...
{% endif %}
{% endfor %}
Replace “123456789” with the id of the collection you created for the smartphone cases.
Hope that helps.
Hey John,
thanks for the reply.
I only have 1 Smartphone-Case Product and one more product, so a total of 2. Is there a collection required then?
Hi,
No, you don’t need to create a collection if there’s only one case. You can just use the product in the conditional.
Having said that, it doesn’t hurt to create a collection for the one case, this way you can add to it if you get more cases in the futue, without having to redo the code.
What would be the code if its only for a product and not a collection? iam really sorry iam a big noob in coding 
No problem.
To do the same thing with a product instead of a collection, the conditional would look something like this:
{% if product.title == "CaseTitle"%}
Code to apply rich-text...
{% else %}
code to not apply rich-text...
{% endif %}
Replace “CaseTitle” with your smartphone case product title.
Hope that helps.
Thanks a lot!! Where should i apply the code? you said apply it to the theme, so you mean by that theme.liquid :D?
No problem.
As far as where to put the code, I’m not exactly sure where the rich-text is supposed to be applied or to what specifically, but if I had to guess I would say that it would be either the product page or the product card snippet, since this is product-specific.
So whatever the product page and the product card snippet files in your theme are called (in the Dawn theme, for example, they’re “main-product.liquid” and “card-product.liquid” respectively), try incorporating the piece code in those and see if what that gives you is satisfactory. If not, then try somewhere else, and see what that gives you, and so on.
Hope that helps.