Hi,
We have a trade b2b & b2c store using Dawn Theme where we hide prices of products from a brand ‘Dahua’ until an approved customer is logged in.
For this Customers have to register an account and when we’ve done our checks, we approve the account by adding a tag to the customer “trade5” and then they can see prices of Dahua products and place orders for them.
So here is the conditional logic I’m trying to apply;
- If the Product Vendor is “dahua” AND
- If the customer tag is “trade5”
Do nothing
Else
Apply CSS style “display: none“ to necessary classes.
For every other brands and products customer must be able to see prices and buy products as normal.
I’ve come up with the following code and it works on product pages but the dual condition doesn’t work on home page and collection pages. If I remove the 2nd condition (Vendor if statement), it works everywhere but then it’s applying the style to all brands and products.
===========
{% assign customersTagsDowncased = customer.tags | downcase %}
{% assign ProductsVendorDowncased = product.vendor | downcase %}
{%- if customersTagsDowncased contains ‘trade5’ -%}
{%- else -%}
{%- if ProductsVendorDowncased contains ‘dahua’ -%}
.product-form__buttons, .price__container, .product__tax, .product-form__input, .card-information, .quick-add { display: none !important;{%- endif -%}
{%- endif -%}
==================
It fails on homepage and collection pages every time I have more than 1 conditional logics.
I’ve tried using product tags instead of vendor and other approaches like using ‘unless’ and ‘for’ tags too - like the one below but they also fail.
=================
{% unless customer.tags contains “trade5” %}
{% if product.vendor contains “dahua” %}
.product-form__buttons, .price__container, .product__tax, .product-form__input, .card-information, .quick-add { display: none !important;{% endif %}
{% endunless %}
=======================
Someone please tell me where I’m going wrong and how to fix it? or if there is a better approach to achieve this without apps.
Preview Store link: https://crwisj4ojn26fg0n-66693726439.shopifypreview.com
Thanks,
NS