On certain products we would like a "call for pricing" or any variance of such. Is there a way so if the product price is $0.00 it will default to "call for pricing?"
So far I was able to add "Call for pricing" adding a simple line of code below, but I would like to hide the price entirely as well. How can I achieve this?
Solved! Go to the solution
Hi @AS_Kits:
Which theme are you using? we need to see a little more of code.
This is an accepted solution.
Using the simple theme, hope this bit of code helps. Just trying to replace anything with a price of $0 to display some text instead...
<p class="product-single__prices"> {% if product.price == 0 %} Call for price {% endif %} {% if product.compare_at_price_max > product.price %} <span id="ComparePriceA11y" class="visually-hidden">{{ 'products.product.sale_price' | t }}</span> {% else %} <span class="visually-hidden">{{ 'products.product.regular_price' | t }}</span> {% endif %} <span id="ProductPrice" class="product-single__price" itemprop="price" content="{{ current_variant.price | divided_by: 100.00 }}"> {{ current_variant.price | money }} </span> {% if product.compare_at_price_max > product.price %} <span id="PriceA11y" class="visually-hidden">{{ 'products.product.regular_price' | t }}</span> <s class="product-single__price--compare" id="ComparePrice"> {{ current_variant.compare_at_price | money }} </s> {% endif %} {% include 'product-unit-price', variant: current_variant, available: true %} </p> {%- if shop.taxes_included or shop.shipping_policy.body != blank -%} <div class="product-single__policies rte"> {%- if shop.taxes_included -%} {{ 'products.product.include_taxes' | t }} {%- endif -%} {%- if shop.shipping_policy.body != blank -%} {{ 'products.product.shipping_policy_html' | t: link: shop.shipping_policy.url }} {%- endif -%} </div> {%- endif -%} {% form 'product', product, class:'product-form' %} <select name="id" id="ProductSelect-{{ section.id }}" class="product-single__variants"> {% for variant in product.variants %} {% if variant.available %} <option {% if variant == product.selected_or_first_available_variant %} selected="selected" {% endif %} data-sku="{{ variant.sku }}" value="{{ variant.id }}">{{ variant.title }} - {{ variant.price | money_with_currency }}</option> {% else %} <option disabled="disabled"> {{ variant.title }} - {{ 'products.product.sold_out' | t }} </option> {% endif %} {% endfor %}
Using Simple Theme, hope this bit of code helps. Just trying to replace anything with $0 with a line of text.
<p class="product-single__prices"> {% if product.price == 0 %} Call for price {% endif %} {% if product.compare_at_price_max > product.price %} <span id="ComparePriceA11y" class="visually-hidden">{{ 'products.product.sale_price' | t }}</span> {% else %} <span class="visually-hidden">{{ 'products.product.regular_price' | t }}</span> {% endif %} <span id="ProductPrice" class="product-single__price" itemprop="price" content="{{ current_variant.price | divided_by: 100.00 }}"> {{ current_variant.price | money }} </span> {% if product.compare_at_price_max > product.price %} <span id="PriceA11y" class="visually-hidden">{{ 'products.product.regular_price' | t }}</span> <s class="product-single__price--compare" id="ComparePrice"> {{ current_variant.compare_at_price | money }} </s> {% endif %} {% include 'product-unit-price', variant: current_variant, available: true %} </p> {%- if shop.taxes_included or shop.shipping_policy.body != blank -%} <div class="product-single__policies rte"> {%- if shop.taxes_included -%} {{ 'products.product.include_taxes' | t }} {%- endif -%} {%- if shop.shipping_policy.body != blank -%} {{ 'products.product.shipping_policy_html' | t: link: shop.shipping_policy.url }} {%- endif -%} </div> {%- endif -%} {% form 'product', product, class:'product-form' %} <select name="id" id="ProductSelect-{{ section.id }}" class="product-single__variants"> {% for variant in product.variants %} {% if variant.available %} <option {% if variant == product.selected_or_first_available_variant %} selected="selected" {% endif %} data-sku="{{ variant.sku }}" value="{{ variant.id }}">{{ variant.title }} - {{ variant.price | money_with_currency }}</option> {% else %} <option disabled="disabled"> {{ variant.title }} - {{ 'products.product.sold_out' | t }} </option> {% endif %} {% endfor %}
This is an accepted solution.
Replace the first part of the code with this:
<p class="product-single__prices"> {% if product.price == 0 %} Call for price {% else %} {% if product.compare_at_price_max > product.price %} <span id="ComparePriceA11y" class="visually-hidden">{{ 'products.product.sale_price' | t }}</span> {% else %} <span class="visually-hidden">{{ 'products.product.regular_price' | t }}</span> {% endif %} <span id="ProductPrice" class="product-single__price" itemprop="price" content="{{ current_variant.price | divided_by: 100.00 }}"> {{ current_variant.price | money }} </span> {% if product.compare_at_price_max > product.price %} <span id="PriceA11y" class="visually-hidden">{{ 'products.product.regular_price' | t }}</span> <s class="product-single__price--compare" id="ComparePrice"> {{ current_variant.compare_at_price | money }} </s> {% endif %} {% include 'product-unit-price', variant: current_variant, available: true %} {% endif %} </p>
Is there another line I can add in there as well to hide the add to cart option if equals $0 as well?
Thank you for your time!
Add the if and endif code around the button tag, like this:
{% if product.price == 0 %} <div class="product-single__cart-submit-wrapper{% if section.settings.enable_payment_button %} product-single__shopify-payment-btn{% endif %}{% if section.settings.add_to_cart_width == 'full_width' %} product-form--full{% endif %}"> <button type="submit" name="add" id="AddToCart" class="btn product-single__cart-submit{% if section.settings.add_to_cart_width == 'full_width' %} btn--full{% endif %}{% if section.settings.enable_payment_button %} shopify-payment-btn btn--secondary{% endif %}" data-cart-url="{{ routes.cart_url }}"> <span id="AddToCartText">{{ 'products.product.add_to_cart' | t }}</span> </button> {% if section.settings.enable_payment_button %} {{ form | payment_button }} {% endif %} </div> {% endif %}
My button tag currently looks like this wrapped in other if/else. Are you able to assist me of how to manage it with this? Thank you!
<div class="product-single__cart-submit-wrapper{% if section.settings.enable_payment_button %} product-single__shopify-payment-btn {% endif %} {% if section.settings.add_to_cart_width == 'full_width' %} product-form--full {% endif %}"> <button type="submit" name="add" id="AddToCart" class="btn product-single__cart-submit {% if section.settings.add_to_cart_width == 'full_width' %} btn--full {% endif %} {% if section.settings.enable_payment_button %} shopify-payment-btn btn--secondary {% endif %}" data-cart-url="{{ routes.cart_url }}"> <span id="AddToCartText">{{ 'products.product.add_to_cart' | t }}</span> </button> {% if section.settings.enable_payment_button %} {{ form | payment_button }} {% endif %} </div> {% endform %}
This is how the code should look
{% if product.price == 0 %} <div class="product-single__cart-submit-wrapper{% if section.settings.enable_payment_button %} product-single__shopify-payment-btn {% endif %} {% if section.settings.add_to_cart_width == 'full_width' %} product-form--full {% endif %}"> <button type="submit" name="add" id="AddToCart" class="btn product-single__cart-submit {% if section.settings.add_to_cart_width == 'full_width' %} btn--full {% endif %} {% if section.settings.enable_payment_button %} shopify-payment-btn btn--secondary {% endif %}" data-cart-url="{{ routes.cart_url }}"> <span id="AddToCartText">{{ 'products.product.add_to_cart' | t }}</span> </button> {% if section.settings.enable_payment_button %} {{ form | payment_button }} {% endif %} </div> {% endif %} {% endform %}
User | Count |
---|---|
735 | |
141 | |
101 | |
64 | |
41 |