Hi,
I’m looking to hide the prices on items that are sold out in my shop- I found the code needed in Liquid, but I really have no idea how to use it. Would anyone be able to help me out?
Thank you!
Bee
Hi,
I’m looking to hide the prices on items that are sold out in my shop- I found the code needed in Liquid, but I really have no idea how to use it. Would anyone be able to help me out?
Thank you!
Bee
How proficient are you in liquid?
You should add the following code to:
{% if product.available %}
/--Price Code--\
{% endif %}
Remove the /–Price Code–\ when trying to add this to your product-template.form file
Let me know!
Thanks for the response!
I am really new to even understanding liquid- is there a step by step tutorial out there for making edits?
Thank you!
I found one called product-form.liquid and another that is product-template.liquid, is one of those right? Do I just copy the contents?
I’m sorry, I’m very unfamiliar with how to do this!
Thank you
sorry, which one of the two I mentioned do you mean? And what editor?
I think I’m going to have to give up on this- I really have no idea how any of this works.
I appreciate you trying to help.
1] product-form.liquid file use for collection page
2] product-template.liquid use for product page
Please share this two file code to me i will checked code and modifying and you will update this code your file .
Let me know
what do you think about this
How do I share it with you? You mentioned pasting it into an editor? Where is that?
{%- comment -%}
Those are the option names for which we automatically detect swatch. For the color, we use them to display a swatch, while
for size, we use it to display a size chart (if applicable)
{%- endcomment -%}
{%- assign color_label = 'color,colour,couleur,colore,farbe,색,色,färg,farve' | split: ',' -%}
{%- assign size_label = 'size,taille,bröße,tamanho,tamaño,koko,サイズ' | split: ',' -%}
{%- assign size_chart_page = '' -%}
{%- assign product_popovers = '' -%}
{%- assign selected_variant = product.selected_or_first_available_variant -%}
{%- form 'product', product, class: 'ProductForm' -%}
{%- unless product.has_only_default_variant -%}
{%- for option in product.options_with_values -%}
{%- assign downcase_option = option.name | downcase -%}
{%- capture popover_id -%}popover-{{ product.id }}-{{ section.id }}-{{ option.name | handle }}{%- endcapture -%}
{%- if section.settings.show_color_swatch and color_label contains downcase_option -%}
{%- assign is_option_with_color_swatch = true -%}
{%- else -%}
{%- assign is_option_with_color_swatch = false -%}
{%- endif -%}
{%- capture popover_html -%}
{%- if color_label contains downcase_option and section.settings.show_color_carousel -%}
{%- for value in option.values -%}
{%- if value == option.selected_value -%}
{%- assign initial_image_index = forloop.index0 -%}
{%- break -%}
{%- endif -%}
{%- endfor -%}
{%- capture flickity_options -%}
{
"prevNextButtons": true,
"pageDots": true,
"initialIndex": {{ initial_image_index }},
"arrowShape": {"x0": 20, "x1": 60, "y1": 40, "x2": 60, "y2": 35, "x3": 25}
}
{%- endcapture -%}
{%- capture option_index -%}option{{ option.position }}{%- endcapture -%}
{%- for value in option.values -%}
{%- for variant in product.variants -%}
{%- if variant[option_index] == value -%}
{%- assign variant_image = variant.image | default: product.featured_image -%}
{%- break -%}
{%- endif -%}
{%- endfor -%}
{%- include 'image-size', sizes: '200,400,600,800', image: variant_image -%}
{%- assign image_url = variant_image | img_url: '1x1' | replace: '_1x1.', '_{width}x.' -%}
{%- endfor -%}
{%- for value in option.values -%}
{%- assign available_prices_for_option_value = '' -%}
{%- for variant in product.variants -%}
{%- if variant[option_index] == value -%}
{%- assign available_prices_for_option_value = available_prices_for_option_value | append: variant.price | append: ',' -%}
{%- endif -%}
{%- endfor -%}
{%- assign available_prices_for_option_value = available_prices_for_option_value | split: ',' | compact | uniq | sort -%}
{%- if is_option_with_color_swatch -%}
{%- assign downcase_value = value | downcase -%}
{%- endif -%}
{{ value }}
{%- if available_prices_for_option_value.size > 1 -%}
{%- capture formatted_min_price -%}{{ available_prices_for_option_value.first | money_without_trailing_zeros }}{%- endcapture -%}
{%- capture formatted_max_price -%}{{ available_prices_for_option_value.last | money_without_trailing_zeros }}{%- endcapture -%}
{{ 'product.form.from_price_html' | t: min_price: formatted_min_price, max_price: formatted_max_price }}
{%- else -%}
{{ available_prices_for_option_value.first | money_without_trailing_zeros }}
{%- endif -%}
{%- endfor -%}
{%- else -%}
{%- for value in option.values -%}
{%- endfor -%}
{%- assign size_chart_page_handle = settings.size_chart_page | default: 'size-chart' -%}
{%- assign size_chart_page = pages[size_chart_page_handle] -%}
{%- if size_label contains downcase_option and size_chart_page != empty -%}
{%- endif -%}
{%- endif -%}
{%- endcapture -%}
{%- assign product_popovers = product_popovers | append: popover_html -%}
{%- endfor -%}
{%- include 'icon' with 'select-arrow' -%}
{%- else -%}
{%- endunless -%}
{%- if section.settings.show_quantity_selector -%}
{%- assign quantity_minus_one = line_item.quantity | minus: 1 -%}
{% include 'icon' with 'minus' %}
{% include 'icon' with 'plus' %}
{%- else -%}
{%- endif -%}
{%- if section.settings.show_inventory_quantity -%}
{%- assign hide_inventory_quantity_by_default = false -%}
{%- if selected_variant.inventory_management == blank or selected_variant.inventory_quantity <= 0 -%}
{%- assign hide_inventory_quantity_by_default = true -%}
{%- endif -%}
{%- if section.settings.inventory_quantity_threshold != 0 and selected_variant.inventory_quantity > section.settings.inventory_quantity_threshold -%}
{%- assign hide_inventory_quantity_by_default = true -%}
{%- endif -%}
{%- if section.settings.inventory_quantity_threshold == 0 -%}
{{- 'product.form.inventory_quantity_count' | t: count: selected_variant.inventory_quantity -}}
{%- else -%}
{{- 'product.form.low_inventory_quantity_count' | t: count: selected_variant.inventory_quantity -}}
{%- endif -%}
{%- endif -%}
{%- comment -%}
--------------------------------------------------------------------------------------------------------------------
ADD TO CART BUTTON
--------------------------------------------------------------------------------------------------------------------
{%- endcomment -%}
{%- if section.settings.show_payment_button -%}
{{ form | payment_button }}
{%- endif -%}
{%- endform -%}
{%- if size_chart_page != empty -%}
{%- comment -%}If we have a size chart we capture the modal content (it must be displayed outside the form for proper positioning){%- endcomment -%}
{%- capture product_modals -%}
{{- size_chart_page.content -}}
{%- endcapture -%}
{%- endif -%}
{%- if section.settings.show_payment_button and selected_variant.available == false -%}
{%- endif -%}
{% comment %}
------------------------------------------------------------------------------
Product Data. This must be outputted for all products (including home page).
IMPORTANT: THIS CODE IS VITAL. DO NOT EDIT IT NOT REMOVE IT. MAKE SURE TO KEEP
THE EXACT SAME ATTRIBUTES.
------------------------------------------------------------------------------
{% endcomment %}
{%- capture section_settings -%}
{
"enableHistoryState": true,
"showInventoryQuantity": {% if section.settings.show_inventory_quantity %}true{% else %}false{% endif %},
"showThumbnails": {% if section.settings.show_thumbnails %}true{% else %}false{% endif %},
"inventoryQuantityThreshold": {{ section.settings.inventory_quantity_threshold }},
"enableImageZoom": {% if section.settings.enable_image_zoom %}true{% else %}false{% endif %},
"showPaymentButton": {{ section.settings.show_payment_button | json }},
"useAjaxCart": {% if settings.cart_type == 'drawer' %}true{% else %}false{% endif %}
}
{%- endcapture -%}
{%- comment -%}
--------------------------------------------------------------------------------------------------------------------
FEATURED IMAGE
We allow merchants to use one image as a "featured image" by adding the alt tag "featured"
--------------------------------------------------------------------------------------------------------------------
{%- endcomment -%}
{%- for image in product.images -%}
{%- if image.alt == 'featured' -%}
{%- assign desk_featured_image = image -%}
{%- endif -%}
{%- if image.alt == 'featured mobile' -%}
{%- assign mobile_featured_image = image -%}
{%- endif -%}
{%- endfor -%}
{%- if desk_featured_image or mobile_featured_image -%}
{%- assign mobile_featured_image = mobile_featured_image | default: desk_featured_image -%}
{%- assign desk_featured_image = desk_featured_image | default: mobile_featured_image -%}
{%- else -%}
{%- endif -%}
{%- comment -%}
--------------------------------------------------------------------------------------------------------------------
MODALS
If we have some videos, we implement them as modal
--------------------------------------------------------------------------------------------------------------------
{%- endcomment -%}
{%- for image in product.images -%}
{%- if image.alt contains 'youtube.com/embed' or image.alt contains 'player.vimeo.com' -%}
{% if image.alt contains 'youtube.com/embed' %}
<iframe class="Image--lazyLoad" data-src="{{ image.alt }}?autoplay=1&showinfo=0&controls=1&rel=0&modestbranding=1" frameborder="0" allowfullscreen=""></iframe>
{% else %}
<iframe class="Image--lazyLoad" data-src="{{ image.alt }}?autoplay=1&portrait=0&byline=0&color={{ settings.accent_color | remove_first: '#' }}" frameborder="0"></iframe>
{% endif %}
{%- endif -%}
{%- endfor -%}
{%- comment -%}
--------------------------------------------------------------------------------------------------------------------
PHOTO SWIPE
This is the root container for the zoom functionality. Must not be removed, as order element is important.
--------------------------------------------------------------------------------------------------------------------
{%- endcomment -%}
{%- if section.settings.enable_image_zoom -%}
{%- endif -%}
{% schema %}
{
"name": "Product page",
"class": "shopify-section--bordered",
"settings": [
{
"type": "checkbox",
"id": "show_share_buttons",
"label": "Show social sharing buttons",
"default": true
},
{
"type": "checkbox",
"id": "show_vendor",
"label": "Show vendor",
"default": true
},
{
"type": "checkbox",
"id": "description_below_add_to_cart",
"label": "Description below add to cart",
"default": false
},
{
"type": "checkbox",
"id": "show_color_swatch",
"label": "Show color swatch",
"default": true,
"info": "Some colors appear white? [Learn more](http://support.maestrooo.com/article/80-product-uploading-custom-color-for-color-swatch)."
},
{
"type": "checkbox",
"id": "show_color_carousel",
"label": "Show color carousel",
"info": "A selector will appear with variant image previews when choosing colors.",
"default": false
},
{
"type": "checkbox",
"id": "show_quantity_selector",
"label": "Show quantity selector",
"default": true
},
{
"type": "checkbox",
"id": "show_inventory_quantity",
"label": "Show inventory quantity",
"info": "Make sure that your inventory is tracked. [Learn more](https://help.shopify.com/manual/products/inventory#set-up-inventory-tracking).",
"default": false
},
{
"type": "range",
"id": "inventory_quantity_threshold",
"label": "Inventory quantity threshold",
"info": "Only show inventory quantity if below threshold. Choose 0 to always show.",
"min": 0,
"max": 50,
"step": 1,
"default": 0
},
{
"type": "checkbox",
"id": "show_payment_button",
"label": "Show dynamic checkout button",
"info": "Lets customers check out directly using a familiar payment method. [Learn more](https://help.shopify.com/manual/using-themes/change-the-layout/dynamic-checkout)",
"default": false
},
{
"type": "header",
"content": "Product images"
},
{
"type": "select",
"id": "image_size",
"label": "Size",
"options": [
{
"value": "small",
"label": "Small"
},
{
"value": "medium",
"label": "Medium"
},
{
"value": "large",
"label": "Large"
},
{
"value": "fill",
"label": "Fill screen"
}
],
"default": "large"
},
{
"type": "checkbox",
"id": "enable_image_zoom",
"label": "Enable zoom",
"default": true
},
{
"type": "checkbox",
"id": "show_thumbnails",
"label": "Show thumbnails",
"info": "Only applicable on large screens",
"default": true
},
{
"type": "header",
"content": "Tabs"
},
{
"type": "page",
"id": "tab_page_1_handle",
"label": "First page"
},
{
"type": "page",
"id": "tab_page_2_handle",
"label": "Second page"
},
{
"type": "paragraph",
"content": "The theme also allows you to add specific tabs for a given product only. [Learn more about this feature](http://support.maestrooo.com/article/83-product-adding-different-tabs-per-product)."
},
{
"type": "header",
"content": "Reviews"
},
{
"type": "paragraph",
"content": "You need to install [Shopify's free Product Reviews](https://apps.shopify.com/product-reviews) app before enabling this option."
},
{
"type": "checkbox",
"id": "reviews_enabled",
"label": "Enable",
"default": false
},
{
"type": "header",
"content": "Featured image"
},
{
"type": "paragraph",
"content": "You can highlight an image after product tabs by adding the ALT tag \"featured\" to a given image. [Learn more](http://support.maestrooo.com/article/152-product-highlight-a-featured-image)."
},
{
"type": "select",
"id": "featured_image_size",
"label": "Section size",
"options": [
{
"value": "small",
"label": "Small"
},
{
"value": "normal",
"label": "Normal"
},
{
"value": "large",
"label": "Large"
}
],
"default": "large"
}
]
}
{% endschema %}
Replace following code your Snippets/product-form.liquid file
{%- comment -%}
Those are the option names for which we automatically detect swatch. For the color, we use them to display a swatch, while
for size, we use it to display a size chart (if applicable)
{%- endcomment -%}
{%- assign color_label = 'color,colour,couleur,colore,farbe,색,色,färg,farve' | split: ',' -%}
{%- assign size_label = 'size,taille,bröße,tamanho,tamaño,koko,サイズ' | split: ',' -%}
{%- assign size_chart_page = '' -%}
{%- assign product_popovers = '' -%}
{%- assign selected_variant = product.selected_or_first_available_variant -%}
{%- form 'product', product, class: 'ProductForm' -%}
{%- unless product.has_only_default_variant -%}
{%- for option in product.options_with_values -%}
{%- assign downcase_option = option.name | downcase -%}
{%- capture popover_id -%}popover-{{ product.id }}-{{ section.id }}-{{ option.name | handle }}{%- endcapture -%}
{%- if section.settings.show_color_swatch and color_label contains downcase_option -%}
{%- assign is_option_with_color_swatch = true -%}
{%- else -%}
{%- assign is_option_with_color_swatch = false -%}
{%- endif -%}
{%- capture popover_html -%}
{%- if color_label contains downcase_option and section.settings.show_color_carousel -%}
{%- for value in option.values -%}
{%- if value == option.selected_value -%}
{%- assign initial_image_index = forloop.index0 -%}
{%- break -%}
{%- endif -%}
{%- endfor -%}
{%- capture flickity_options -%}
{
"prevNextButtons": true,
"pageDots": true,
"initialIndex": {{ initial_image_index }},
"arrowShape": {"x0": 20, "x1": 60, "y1": 40, "x2": 60, "y2": 35, "x3": 25}
}
{%- endcapture -%}
{%- capture option_index -%}option{{ option.position }}{%- endcapture -%}
{%- for value in option.values -%}
{%- for variant in product.variants -%}
{%- if variant[option_index] == value -%}
{%- assign variant_image = variant.image | default: product.featured_image -%}
{%- break -%}
{%- endif -%}
{%- endfor -%}
{%- include 'image-size', sizes: '200,400,600,800', image: variant_image -%}
{%- assign image_url = variant_image | img_url: '1x1' | replace: '_1x1.', '_{width}x.' -%}
{%- endfor -%}
{%- for value in option.values -%}
{%- assign available_prices_for_option_value = '' -%}
{%- for variant in product.variants -%}
{%- if variant[option_index] == value -%}
{%- assign available_prices_for_option_value = available_prices_for_option_value | append: variant.price | append: ',' -%}
{%- endif -%}
{%- endfor -%}
{%- assign available_prices_for_option_value = available_prices_for_option_value | split: ',' | compact | uniq | sort -%}
{%- if is_option_with_color_swatch -%}
{%- assign downcase_value = value | downcase -%}
{%- endif -%}
{{ value }}
{% if product.available %}
{%- if available_prices_for_option_value.size > 1 -%}
{%- capture formatted_min_price -%}{{ available_prices_for_option_value.first | money_without_trailing_zeros }}{%- endcapture -%}
{%- capture formatted_max_price -%}{{ available_prices_for_option_value.last | money_without_trailing_zeros }}{%- endcapture -%}
{{ 'product.form.from_price_html' | t: min_price: formatted_min_price, max_price: formatted_max_price }}
{%- else -%}
{{ available_prices_for_option_value.first | money_without_trailing_zeros }}
{%- endif -%}
{% endif %}
{%- endfor -%}
{%- else -%}
{%- for value in option.values -%}
{%- endfor -%}
{%- assign size_chart_page_handle = settings.size_chart_page | default: 'size-chart' -%}
{%- assign size_chart_page = pages[size_chart_page_handle] -%}
{%- if size_label contains downcase_option and size_chart_page != empty -%}
{%- endif -%}
{%- endif -%}
{%- endcapture -%}
{%- assign product_popovers = product_popovers | append: popover_html -%}
{%- endfor -%}
{%- include 'icon' with 'select-arrow' -%}
{%- else -%}
{%- endunless -%}
{%- if section.settings.show_quantity_selector -%}
{%- assign quantity_minus_one = line_item.quantity | minus: 1 -%}
{% include 'icon' with 'minus' %}
{% include 'icon' with 'plus' %}
{%- else -%}
{%- endif -%}
{%- if section.settings.show_inventory_quantity -%}
{%- assign hide_inventory_quantity_by_default = false -%}
{%- if selected_variant.inventory_management == blank or selected_variant.inventory_quantity <= 0 -%}
{%- assign hide_inventory_quantity_by_default = true -%}
{%- endif -%}
{%- if section.settings.inventory_quantity_threshold != 0 and selected_variant.inventory_quantity > section.settings.inventory_quantity_threshold -%}
{%- assign hide_inventory_quantity_by_default = true -%}
{%- endif -%}
{%- if section.settings.inventory_quantity_threshold == 0 -%}
{{- 'product.form.inventory_quantity_count' | t: count: selected_variant.inventory_quantity -}}
{%- else -%}
{{- 'product.form.low_inventory_quantity_count' | t: count: selected_variant.inventory_quantity -}}
{%- endif -%}
{%- endif -%}
{%- comment -%}
--------------------------------------------------------------------------------------------------------------------
ADD TO CART BUTTON
--------------------------------------------------------------------------------------------------------------------
{%- endcomment -%}
{%- if section.settings.show_payment_button -%}
{{ form | payment_button }}
{%- endif -%}
{%- endform -%}
{%- if size_chart_page != empty -%}
{%- comment -%}If we have a size chart we capture the modal content (it must be displayed outside the form for proper positioning){%- endcomment -%}
{%- capture product_modals -%}
{{- size_chart_page.content -}}
{%- endcapture -%}
{%- endif -%}
{%- if section.settings.show_payment_button and selected_variant.available == false -%}
{%- endif -%}
{% comment %}
------------------------------------------------------------------------------
Product Data. This must be outputted for all products (including home page).
IMPORTANT: THIS CODE IS VITAL. DO NOT EDIT IT NOT REMOVE IT. MAKE SURE TO KEEP
THE EXACT SAME ATTRIBUTES.
------------------------------------------------------------------------------
{% endcomment %}
Hi @dmwwebartisan , I am having this same issue as the OP as I also want to hide the price of all the sold-out items in my Prestige theme. I have already copied and pasted your code into the Snippets/product.form.liquid file but the price is still visible. My website is https://www.airshroud.com. I hope you could help me as you did for the OP, thanks.
Hi @dmwwebartisan Thanks for the swift response. I found a work around to what I want to achieve so it’s cool now. Thanks anyway.
Hello,
I have the same issue with it.
I can not hide the item price which is sold out already.
I would like to hide the price on the item details page and item list pages as well.
I tried to use the attached code but I failed
Please help me !
Best wishes
Hello @dmwwebartisan
I have the same issue, I copied and pasted your code into the snippets/product.form.liquid but is not working for me. The prices are still visible.
My website is: www.beachtennisdepot.com
I hope you can help me
Thanks!
Hello! Is this code still active / possible? I’ve been trying several codings to hide the prices of the sold out items within the prestige theme but without success. Anyone any tips?