Remove add to cart button unavailable products

Hello, my shop is infinitycosmetics.it

I want to remove add to cart button under unavailable products, anyone can help me?

Currently there is the “out of stock” label, but customers can still add the product to the cart because the button is there. I would like to remove the button from out of stock products.

currently there is the “out of stock” label, but customers can still add the product to the cart because the button is there. I would like to remove the button from out of stock products.

ordinarily most of the theme will make this product unavailable for add to cart if it is out of stock, unless you have specifically ticked the option to “continue selling when out of stock”. Please check in your admin dashboard - go to the specific product, and under inventory section, do you have that ticked? If you untick it, the customer should not be able to buy / add to cart.

It is already unticked

I want to show unaivalable products but I don’t want to add to cart

What theme are you using? It is hard to guess whether the issue is with theme configuration or backend. But to be honest, I find it hard to believe any well designed theme would just keep selling even out of stock without giving user the ability to untick. If it is a custom theme, I would suggest to reach out to the theme developer.

Otherwise, can you please provide the liquid code so I can try to check? The add to cart component should be inside product.liquid.

You can add a liquid logic inside the code basically says something like below, but you kind of need to know where to add that. Basically find the add to cart button, and add the last few lines of code inside it.

<button
  type="submit"
  name="add"
  {% if product.selected_or_first_available_variant.available == false %}
    disabled
  {% endif %}
>   

I tryed but it doesn’t work.

THIS IS MY THEME.LIQUID CODE

{% unless request.path contains ‘/account’ %} {% assign restrict_page = true %} {% endunless %}
{% if shop.metafields.adv_reg.noFraming == ‘on’ %} {% assign restrict_page = true %}{% endif %}
{% if shop.metafields.adv_reg.useBlacklist == ‘on’ %}
{% assign restrict_page = false %}
{% assign blockPages = shop.metafields.adv_reg.blockPageUrls | split: “|” %}
{% for url in blockPages %}
{% if request.path == url %}{% assign restrict_page = true %} {% endif %}
{% endfor %}
{% else %}
{% assign exceptionUrls = shop.metafields.adv_reg.lockShopExceptionUrls | split: “|” %}
{% for url in exceptionUrls %}
{% if request.path == url %}{% assign restrict_page = false %} {% endif %}
{% endfor %}
{% endif %}

{% if request.path == ‘/challenge’ %} {% assign restrict_page = false %} {% endif %}
{% if request.path == ‘/password’ %} {% assign restrict_page = false %} {% endif %}
{% if request.path == ‘/account/recover’ %} {% assign restrict_page = false %} {% endif %}

{% if request.path contains ‘/tools/emails’ %} {% assign restrict_page = false %} {% endif %}

{% if request.path contains ‘/account/reset’ %} {% assign restrict_page = false %} {% endif %}
{% if request.path contains ‘/account/activate’ %} {% assign restrict_page = false %} {% endif %}

{% if request.path contains ‘/reset-password’ %} {% assign restrict_page = false %} {% endif %}
{% if request.path contains ‘/customer-account-password-reset’ %} {% assign restrict_page = false %} {% endif %}

{% if shop.metafields.adv_reg.lockShop == ‘on’ and customer == nil and restrict_page %}

{% if shop.metafields.adv_reg.noFraming == ‘on’ %}
{% include ‘advanced_registration_locked_page’ %}
{% else %}

{% render ‘judgeme_core’ %}

{% include "starapps-core" %}

{%- render ‘layouthub_header’ -%}{% render ‘pagefly-head’ %}

{{page_title}} {% if page_description %} {% endif %} {% if shop.metafields.adv_reg.showRegistrationPageFirst == 'on' %} {% else %} {% endif %} {% render 'wsg-custom' %} {% endif %} {% else %} {% include "starapps-core" %}

{%- render ‘layouthub_header’ -%}

{{ page_title }}{% if current_tags %}{% assign meta_tags = current_tags | join: ', ' %} – {{ 'general.meta.tags' | t: tags: meta_tags }}{% endif %}{% if current_page != 1 %} – {{ 'general.meta.page' | t: page: current_page }}{% endif %}{% unless page_title contains shop.name %} – {{ shop.name }}{% endunless %}

{% if page_description %}

{% endif %}

{% if template contains ‘product’ %}

{% else %}

{% endif %}

{% render ‘social-meta-tags’ %}
{% render ‘css-variables’ %}

{{ ‘theme.min.css’ | asset_url | stylesheet_tag }}
{{ ‘custom.css’ | asset_url | stylesheet_tag }}

{% render ‘font-links’ %}

{% if settings.favicon != blank %}

{% endif %}

{% render “starapps-product-json”, product: product, starapps_app: “VIA”, starapps_attribute: “sa-product-json” %}

{{ content_for_header }}

{% if template contains ‘customers’ %}
{{ “shopify_common.js” | shopify_asset_url | script_tag }}
{{ “customer_area.js” | shopify_asset_url | script_tag }}
{% endif %}

{% include ‘productwiz-rio’ %}

{% include ‘bss-product-labels-configs’ %}
{% render ‘wishlisthero-styles.liquid’ %}

{% render ‘wsg-custom’ %}

{% if template != ‘cart’ %}
{% render ‘cart-drawer’ %}
{% endif %}

{% section ‘announcement-bar’ %}
{% section ‘header’ %}

{% unless template == “index” or template == “collection” %}

{% endunless %} {{ content_for_layout }}

{% include ‘station-tabs’ %}

{% unless template == “index” or template == “collection” %}

{% endunless %}

{% section ‘footer’ %}

{% render ‘popup’ %}

{% include ‘productpageswatchsnippet’ %}{% include ‘swatchyappvariables’ %}{% include ‘social-login’ %}{{ ‘ndnapps-sociallogin.css’ | asset_url | stylesheet_tag }}
{% if shop.customer_accounts_enabled %}{% unless customer %}{{ ‘ndnapps-sociallogin-script.js’ | asset_url | script_tag }}{% endunless %}{% endif %}

{% include ‘pointkit_snippet’ %}

{% comment %} sc_discountbox include {% endcomment %}
{% include ‘sc-discount-app’ %}
{% comment %} end of sc_discountbox include {% endcomment %}

{% render ‘spurit_wsmm-theme-snippet’ %}

{% if customer.tags.size > 0 and template != ‘cart’ %}

{% endif %}

{% if customer.tags.size > 0 and template == ‘cart’ %}
{% include ‘wcp_cart’ %}
{% endif %}

{%- render ‘layouthub_footer’ -%}
{% render ‘spurit_dmr_theme_snippet’ %}

{% endif %}

ENVY THEME, and this is my TEMPLATE–PRODUCT.LIQUID CODE

{% unless product.tags contains “gift_product” %}

{%- assign product_thumb_size = ‘160x160’ -%}
{%- assign product_image_zoom_size = ‘1024x1024’ -%}

{% comment %}Pick an option only makes sense together with dropdowns{% endcomment %}
{% if settings.show_swatches == false and section.settings.pick_an_option %}
{% assign pick_an_option = true %}
{% else %}
{% assign pick_an_option = false %}
{% endif %}

{% if pick_an_option %}
{%- assign current_variant = product.selected_variant -%}
{% else %}
{%- assign current_variant = product.selected_or_first_available_variant -%}
{% endif %}
{%- assign featured_image = current_variant.featured_image | default: product.featured_image -%}

{% comment %}
Check if the product is on sale and set a variable to be used below.
{% endcomment %}
{% assign on_sale = false %}
{% if current_variant.compare_at_price > current_variant.price %}
{% assign on_sale = true %}
{% endif %}

{% assign full_width = false %}
{% if section.settings.image_size == ‘full-width’ %}
{% assign full_width = true %}
{% endif %}

{% case section.settings.image_size %}
{% when ‘small’ %}
{%- assign product_image_width = 6 -%}
{%- assign product_image_size = ‘345x’ -%}
{% when ‘medium’ %}
{%- assign product_image_width = 7 -%}
{%- assign product_image_size = ‘530x’ -%}
{% when ‘large’ %}
{%- assign product_image_width = 8 -%}
{%- assign product_image_size = ‘720x’ -%}
{% when ‘full-width’ %}
{%- assign product_image_width = 12 -%}
{%- assign product_image_size = ‘900x’ -%}
{% endcase %}

{% if section.settings.thumbnail_position == ‘below’ or product.images.size <= 1 %}
{% case section.settings.image_size %}
{% when ‘small’ %}
{%- assign product_description_width = ‘col-md-6’ -%}
{% when ‘medium’ %}
{%- assign product_description_width = ‘col-md-5’ -%}
{% when ‘large’ %}
{%- assign product_description_width = ‘col-md-4’ -%}
{% when ‘full-width’ %}
{%- assign product_description_width = ‘col-md-12’ -%}
{% endcase %}
{% else %}
{% case section.settings.image_size %}
{% when ‘small’ %}
{%- assign product_description_width = ‘col-md-5’ -%}
{% when ‘medium’ %}
{%- assign product_description_width = ‘col-md-4’ -%}
{% when ‘large’ %}
{%- assign product_description_width = ‘col-md-3’ -%}
{% when ‘full-width’ %}
{%- assign product_description_width = ‘col-md-12’ -%}
{% endcase %}
{% endif %}

{{ 'general.breadcrumbs.home' | t }}

{% if collection %}

{% if collection.handle %}
{% capture url %}/collections/{{ collection.handle }}{% endcapture %}
{{ collection.title | link_to: url }}
{% endif %}
{% endif %}

{{ product.title }}

{% capture thumbnails %}

{% if settings.sale_badge %}
{{ 'products.general.sale' | t }}
{% endif %} {% if product.media.size > 0 %}
{% assign featured_media = current_variant.featured_media | default: product.featured_media %} {% render 'product-media', product: product, section_id: section.id, featured_media_id: featured_media.id, enable_image_zoom: section.settings.enable_zoom, enable_video_loop: section.settings.enable_video_loop %}
{% endif %}
{% endcapture %}
{% if section.settings.thumbnail_position == 'left' %} {{ thumbnails }} {% endif %}

{% if settings.sale_badge %}

{{ 'products.general.sale' | t }}
{% endif %}
{% comment %}Medias for thumbnails will go here on desktop{% endcomment %} {% if product.media.size == 0 %} {{ 'product-1' | append: current | placeholder_svg_tag: 'icon--placeholder' }} {% endif %}

{% if section.settings.thumbnail_position == ‘below’ %}
{{ thumbnails }}
{% endif %}

{% if section.settings.thumbnail_position == 'right' %} {{ thumbnails }} {% endif %}

{% capture out_of_stock_email_form %}

{% form 'contact' %}

{{ 'products.product.thanks' | t }}

{% if form.posted_successfully? %} .stock-notice{ display:none; } {% else %} {{ 'products.product.out-stock_html' | t: product: product.title }} {% endif %} {% if form.errors %}
{{ 'products.product.wrong-email' | t }}
{% endif %} {% unless form.posted_successfully? %}
{% if customer %} {% else %} {% endif %}
{% endunless %} {% endform %}
{% endcapture %}
{% if settings.show_vendor or settings.show_SKU %}
{% if settings.show_vendor %}
{{ product.vendor }}
{% endif %} {% if settings.show_SKU %}
{{ current_variant.sku }}
{% endif %}
{% endif %}

{{ product.title }}

{% render 'judgeme_widgets', widget_type: 'judgeme_preview_badge', jm_style: '', concierge_install: true, product: product %} {% if settings.show_reviews %} {% endif %}

{% if full_width %}

{% endif %}

{% if section.settings.description_position == “below” %}
{% if full_width %}

{% endif %}
{{ product.description }}

{% if full_width %}

{% endif %} {% endif %}

{% if full_width %}

{% endif %}

{% if product.available %}

{% form ‘product’, product, id: “add-to-cart-form” %}

  • {% if pick_an_option %} {{ 'products.product.make_a_selection' | t }} {% elsif current_variant.available %} {{ current_variant.price | money }} {% else %} {{ "products.product.sold_out" | t }} {% assign on_sale = false %} {% endif %}
  • {{ current_variant.compare_at_price | money }}
  • {% render ‘unit-price-measurement-variant’, variant: current_variant %}

{% unless section.settings.show_discount == ‘hide’ %}

{% case section.settings.show_discount %} {% when 'percentage' %} - {{ current_variant.compare_at_price | minus: current_variant.price | times: 100.0 | divided_by: current_variant.compare_at_price | money_without_currency | times: 100 | remove: '.0'}}% {% when 'value' %} - {{ current_variant.compare_at_price | minus: current_variant.price | money }} {% endcase %}
{% endunless %}

{% assign hide_default_title = false %}
{% if product.variants.size == 1 and product.variants.first.title contains ‘Default’ %}
{% assign hide_default_title = true %}
{% endif %}

{% if product.variants.size > 0 %}

{% if settings.show_swatches %}

{% if product.variants.size > 1 %}
{% for option in product.options %}
{% render ‘swatch’ with option, product: product, section: section %}
{% endfor %}
{% endif %}

{% else %}

{% for option in product.options_with_values %}

{{ option.name }}
{% endfor %}

{% endif %}

{% endif %}

{% if section.settings.show_quantity_selector %}

{{ 'products.product.quantity' | t }}
- +
{% endif %}
{% assign disabled = pick_an_option %} {% unless current_variant.available %} {% assign disabled = true %} {% endunless %} {% if pick_an_option or current_variant.available %} {{ 'products.product.add_to_cart' | t }} {% else %} {{ 'products.product.sold_out' | t }} {% endif %}

{% if section.settings.show_smart_checkout %}
{{ form | payment_button }}
{% endif %}

{% endform %}

{% if section.settings.show_out_of_stock_email %}

{{ out_of_stock_email_form }}
{% endif %}

{% else %}

{{ 'products.product.sorry_stock' | t }}

{% if section.settings.show_out_of_stock_email %} {{ out_of_stock_email_form }} {% endif %}

{% endif %}

{% if full_width %}

{% endif %}

{% if section.settings.description_position == “above” %}

{% if full_width %}

{% endif %}
{{ product.description }}

{% if full_width %}

{% endif %}

{% endif %}

{% if full_width %}

{% endif %} {% render 'social-sharing' %} {% if full_width %}
{% endif %}

{% if full_width %}

{% endif %}

{% unless product.empty? %}

{% endunless %}

{% render 'judgeme_widgets', widget_type: 'judgeme_review_widget', concierge_install: true, product: product %} {% if settings.show_reviews %}
{{ product.metafields.spr.reviews }}
{% endif %} {% endunless %} {% schema %} { "name": { "en": "Product pages", "de": "Produktseiten", "es": "Páginas de producto", "fr": "Pages des produits", "pt-PT": "Páginas de produtos" }, "settings": [ { "type": "checkbox", "id": "show_quantity_selector", "label": { "en": "Show quantity selector", "de": "Anzahlauswähler anzeigen", "es": "Mostrar selector de cantidad", "fr": "Afficher le sélecteur de quantité", "pt-PT": "Mostrar selecionador de quantidade" }, "default": true }, { "type": "checkbox", "id": "show_smart_checkout", "label": { "en": "Show dynamic checkout button", "de": "Dynamischen Bezahlbutton anzeigen", "es": "Mostar el botón de compra dinámica", "fr": "Afficher le bouton de paiement dynamique", "pt-PT": "Mostrar botão de checkout dinâmico" }, "default": true, "info": { "en": "Lets customers check out directly using a familiar payment method. [Learn more]([https://help.shopify.com/manual/using-themes/change-the-layout/dynamic-checkout](https://help.shopify.com/manual/using-themes/change-the-layout/dynamic-checkout))", "de": "Lässt Kunden direkt unter Verwendung einer bekannten Zahlungsmethode bezahlen. [Mehr erfahren]([https://help.shopify.com/manual/using-themes/change-the-layout/dynamic-checkout](https://help.shopify.com/manual/using-themes/change-the-layout/dynamic-checkout))", "es": "Permita a los clientes finalizar su compra directamente utilizando un método de pago que les sea familiar. [Aprenda más]([https://help.shopify.com/manual/using-themes/change-the-layout/dynamic-checkout](https://help.shopify.com/manual/using-themes/change-the-layout/dynamic-checkout))", "fr": "Permet aux clients de payer directement en utilisant un mode de paiement familier. [En savoir plus]([https://help.shopify.com/manual/using-themes/change-the-layout/dynamic-checkout](https://help.shopify.com/manual/using-themes/change-the-layout/dynamic-checkout))", "pt-PT": "Permita que os clientes façam checkout diretamente utilizando um método de pagamento familiar. [Saber mais]([https://help.shopify.com/manual/using-themes/change-the-layout/dynamic-checkout](https://help.shopify.com/manual/using-themes/change-the-layout/dynamic-checkout))" } }, { "type": "checkbox", "id": "show_variant_labels", "label": { "en": "Show variant labels", "de": "Variantenbezeichnungen anzeigen", "es": "Mostrar etiquetas de las variantes", "fr": "Afficher les étiquettes des variantes", "pt-PT": "Mostrar etiquetas variantes" }, "default": true }, { "type": "checkbox", "id": "thumbnail_changes_variant", "label": { "en": "Change variant based on the thumbnail", "de": "Variante basierend auf Thumbnail verändern", "es": "Cambiar variante en base a la imagen en miniatura", "fr": "Modifier la variante en fonction de la vignette", "pt-PT": "Alterar base da variante na imagem em miniatura" }, "default": false }, { "type": "checkbox", "id": "show_out_of_stock_email", "label": { "en": "Enable out of stock email", "de": "Die E-Mail \"Nicht lieferbar\" aktivieren", "es": "Habilitar correo electrónico agotado", "fr": "Activer le courriel Rupture de stock", "pt-PT": "Ativar e-mail de esgotado" }, "default": false }, { "type": "checkbox", "id": "hide_out_of_stock", "label": { "en": "Hide out of stock variants", "de": "Nicht lieferbare Varianten verbergen", "es": "Ocultar las variantes en el stock", "fr": "Masquer les variantes en rupture de stock", "pt-PT": "Ocultar variantes em falta" }, "default": false, "info": { "en": "Hide variants that are out of stock when there's one variant set", "de": "Nicht lieferbare Varianten verbergen, wenn eine Variante eingestellt ist", "es": "Oculta las variantes que no están disponibles en el stock cuando hay un grupo de variaciones", "fr": "Masquer les variantes en rupture de stock lorsqu'il n'y a qu'un seul ensemble de variantes.", "pt-PT": "Ocultar variantes em falta quando houver uma variante definida" } }, { "type": "radio", "id": "description_position", "label": { "en": "Cart button location", "de": "Einkaufswagen-Button-Ort", "es": "Ubicación del botón del carrito", "fr": "Emplacement du bouton du panier", "pt-PT": "Localização do botão do carrinho" }, "options": [ { "value": "above", "label": { "en": "Before product description", "de": "Vor der Produktbeschreibung", "es": "Cargar más botones", "fr": "Avant la description du produit", "pt-PT": "Antes da descrição do produto" } }, { "value": "below", "label": { "en": "After product description", "de": "Nach der Produktbeschreibung", "es": "Después de la descripción del producto", "fr": "Après la description du produit", "pt-PT": "Depois da descrição do produto" } } ], "default": "above" }, { "type": "radio", "id": "cart-action", "label": { "en": "Add to Cart action", "de": "Aktion „Zum Einkaufswagen hinzufügen“", "es": "Acción de Añadir al carrito", "fr": "Action d'ajout au panier", "pt-PT": "Ação Adicionar ao Carrinho" }, "options": [ { "value": "drawer", "label": { "en": "Show drawer", "de": "Schublade zeigen", "es": "Mostrar cajón", "fr": "Afficher le tiroir", "pt-PT": "Mostrar gaveta" } }, { "value": "added", "label": { "en": "Show 'Added' message", "de": "„Hinzugefügt“-Mitteilung zeigen", "es": "Mostar el mensaje de «Añadido»", "fr": "Afficher le message « Ajouté »", "pt-PT": "Mostrar mensagem \"Adicionado\"" } }, { "value": "cart", "label": { "en": "Go to cart", "de": "Zum Einkaufswagen gehen", "es": "Ir al carrito", "fr": "Aller au panier", "pt-PT": "Ir para o carrinho" } } ] }, { "type": "checkbox", "id": "pick_an_option", "label": { "en": "Enable 'Pick an option'", "de": "„Eine Option auswählen“ aktivieren", "es": "Habilitar «Escoja una opción»", "fr": "Activez « Choisir une option ».", "pt-PT": "Ativar \"Escolher uma opção\"" }, "default": false }, { "type": "select", "id": "show_discount", "label": { "en": "Enable discount savings?", "de": "Rabattersparnisse aktivieren?", "es": "¿Habilitar ahorros por descuentos?", "fr": "Permettre des économies de rabais ?", "pt-PT": "Ativar promoções?" }, "options": [ { "value": "hide", "label": { "en": "Hide", "de": "Verbergen", "es": "Ocultar", "fr": "Cacher", "pt-PT": "Ocultar" } }, { "value": "percentage", "label": { "en": "Percentage", "de": "Prozentsatz", "es": "Porcentaje", "fr": "Pourcentage", "pt-PT": "Percentagem" } }, { "value": "value", "label": { "en": "Value", "de": "Wert", "es": "Valor", "fr": "Valeur", "pt-PT": "Valor" } } ], "default": "hide", "info": { "en": "Discounts will only be shown on variants that are on sale", "de": "Rabatte werden nur auf Varianten angezeigt, die im Angebot sind", "es": "Los descuentos solo se mostrarán en las variantes que están de oferta.", "fr": "Les remises ne s'appliqueront qu'aux variantes en vente.", "pt-PT": "Os descontos apenas serão exibidos em variantes que estejam à venda" } }, { "type": "header", "content": { "en": "Social sharing", "de": "Soziales Teilen", "es": "Compartir en redes sociales", "fr": "Partager sur les réseaux sociaux", "pt-PT": "Partilha social" } }, { "type": "checkbox", "id": "social_sharing_facebook", "label": { "en": "Facebook", "de": "Facebook", "es": "Facebook", "fr": "Facebook", "pt-PT": "Facebook" }, "default": true }, { "type": "checkbox", "id": "social_sharing_twitter", "label": { "en": "Twitter", "de": "Twitter", "es": "Twitter", "fr": "Twitter", "pt-PT": "Twitter" }, "default": true }, { "type": "checkbox", "id": "social_sharing_pinterest", "label": { "en": "Pinterest", "de": "Pinterest", "es": "Pinterest", "fr": "Pinterest", "pt-PT": "Pinterest" }, "default": true }, { "type": "header", "content": { "en": "Media", "de": "Medien", "es": "Medios de comunicación", "fr": "Médias", "pt-PT": "Multimédia" }, "info": { "en": "Learn more about [media types]([https://help.shopify.com/manual/products/product-media](https://help.shopify.com/manual/products/product-media))", "de": "Mehr Informationen über [Medientypen ]([https://help.shopify.com/manual/products/product-media](https://help.shopify.com/manual/products/product-media))", "es": "Más información sobre [tipos de archivos multimedia]([https://help.shopify.com/manual/products/product-media](https://help.shopify.com/manual/products/product-media))", "fr": "En savoir plus sur les [types de supports multimédia]([https://help.shopify.com/manual/products/product-media](https://help.shopify.com/manual/products/product-media))", "pt-PT": "Saiba mais sobre [media types]([https://help.shopify.com/manual/products/product-media](https://help.shopify.com/manual/products/product-media))" } }, { "type": "select", "id": "image_size", "label": { "en": "Size", "de": "Größe", "es": "Tamaño", "fr": "Taille", "pt-PT": "Tamanho" }, "options": [ { "value": "small", "label": { "en": "Small", "de": "Klein", "es": "Pequeño", "fr": "Petite", "pt-PT": "Pequeno" } }, { "value": "medium", "label": { "en": "Medium", "de": "Mittel", "es": "Mediano", "fr": "Moyenne", "pt-PT": "Médio" } }, { "value": "large", "label": { "en": "Large", "de": "Groß", "es": "Grande", "fr": "Grande", "pt-PT": "Grande" } }, { "value": "full-width", "label": { "en": "Full width", "de": "Volle Breite", "es": "Ancho completo", "fr": "Pleine largeur", "pt-PT": "Largura total" } } ], "default": "medium" }, { "type": "select", "id": "thumbnail_position", "label": { "en": "Thumbnail position", "de": "Thumbnail-Position", "es": "Posición de la imagen en miniatura", "fr": "Position de la vignette", "pt-PT": "Posição da imagem em miniatura" }, "options": [ { "value": "below", "label": { "en": "Below main image", "de": "Unter Hauptbild", "es": "Debajo de la imagen principal", "fr": "Image principale ci-dessous", "pt-PT": "Imagem principal abaixo" } }, { "value": "left", "label": { "en": "Left of main image", "de": "Links auf Hauptbild", "es": "A la izquierda de la imagen principal", "fr": "Partie gauche de l'image principale", "pt-PT": "Esquerda da imagem principal" } }, { "value": "right", "label": { "en": "Right of main image", "de": "Rechts auf Hauptbild", "es": "A la derecha de la imagen principal", "fr": "Partie droite de l'image principale", "pt-PT": "Direita da imagem principal" } } ], "default": "below" }, { "type": "checkbox", "id": "enable_zoom", "label": { "en": "Enable image zoom", "de": "Bildzoom aktivieren", "es": "Habilitar zoom sobre la imagen", "fr": "Activer le zoom de l'image", "pt-PT": "Ativar zoom de imagem" }, "default": true }, { "type": "checkbox", "id": "enable_video_loop", "label": { "de": "Videschleife aktivieren", "en": "Enable video looping", "es": "Habilitar la reproducción de video en bucle", "fr": "Activer le bouclage de la vidéo", "pt-PT": "Ativar ciclo de vídeo" }, "default": false } ] } {% endschema %} {% render 'judgeme_widgets', widget_type: 'judgeme_review_widget', concierge_install: true, product: product %}

The problem is in the collections page, in product pages is ok.

You can’t add this to the theme code, that is not where it should be added.

Looks like you are using the Envy theme, is it the Envy 2.0? Their support should be able to help you if you need help on theme.

If you are using 2.0, then go to Edit Code → Snippets → card-product.liquid, and find:

{%- if show_quick_add -%}

And then find . The following code should resemble something like this. It might have a different class name or some sorts, as i don’t know the liquid code inside Envy. But again the important bit is the if logic. If you don’t know what you need to do, find the relevant line in your liquid file, and paste in the thread so I can see it.

<button
  id="{{ product_form_id }}-submit"
  type="submit"
  name="add"
  class="quick-add__submit button button--full-width button--secondary"
  aria-haspopup="dialog"
  aria-labelledby="{{ product_form_id }}-submit title-{{ section_id }}-{{ card_product.id }}"
  aria-live="polite"
  data-sold-out-message="true"
 **{% if card_product.selected_or_first_available_variant.available == false %}**
 **disabled**
 **{% endif %}**
>

My theme is ENVY version 26.3.0 and I can’t find card-product.liquid

Oh, you are not on the 2.0 themes. The shopify 2.0 themes are structured differently.

Can you see this?

Edit Code → Snippet → product-grid-item.liquid?

Can you please copy and paste the code from that file in this thread? I assume the theme has some customisation there to enable the add to cart.

I see product-grid–indiv-product.liquid and product-grid–onboarding-product.liquid

Can you copy and paste the code for both files? It is hard to gauge which one, as both seem to be bespoke to the theme itself.

Alternatively, if you had bought the theme, you really should reach out to the theme developer via the shopify theme store, they should be able to help you much faster.

Yes, I found my Add to cart button in product-grid–indiv-product.liquid file, this is the code:

{% assign crop_setting = settings.product-grid %}
{% if crop_setting == “square” %}
{% assign image_crop = “aspect-ratio–square” %}
{% elsif crop_setting == “tall” %}
{% assign image_crop = “aspect-ratio–tall” %}
{% elsif crop_setting == “wide” %}
{% assign image_crop = “aspect-ratio–wide” %}
{% endif %}

{% case settings.hover-effect %}

{% when ‘none’ %}

{% if image_crop %}
{% endif %} {% render 'responsive-image' with liquidObject.media[0].preview_image, alt: liquidObject.title %} {% if image_crop %}
{% endif %}

{% when ‘second-image’ %}

{% if liquidObject.media.size > 1 %}

{% else %} {% if image_crop %}
{% endif %} {% render 'responsive-image' with liquidObject.media[0].preview_image, alt: liquidObject.title %} {% if image_crop %}
{% endif %}
{% endif %}

{% when ‘zoom’ %}

{{ }}

{% endcase %}

{% if settings.show_swatches %}

{% for option in liquidObject.options %}

{% capture downcased_option %}{{ option | downcase }}{% endcapture %}
{% assign option_handle = option | handle %}
{% assign option_index = forloop.index0 %}
{% assign prod_id = liquidObject.id %}

{% if downcased_option contains ‘color’ or downcased_option contains ‘colour’ %}
{% if product.variants.size > 1 %}

{% assign values = ‘’ %}
{% for variant in product.variants %}

{% assign variantID = variant.id %}

{% assign value = variant.options[option_index] %}
{% capture wrapped_value %},{{ value }},{% endcapture %}
{% unless values contains wrapped_value %}

{% if variant.image %}
{% assign image = variant.image | product_img_url: ‘400x’ %}
{% else %}
{% assign image = liquidObject.media[0].preview_image | product_img_url: ‘400x’ %}
{% endif %}

{% capture values %}{{ values }}{{ wrapped_value }}{% endcapture %}
{% endunless %}

{% endfor %}

{% endif %} {% endif %}

{% endfor %}
{% endif %}

{% if liquidObject.available %}
{% if liquidObject.compare_at_price_max > liquidObject.price and settings.sale_badge %}

{{ 'products.general.sale' | t }}
{% endif %} {% elsif settings.sold_out_badge %}
{{ 'products.product.sold_out' | t }}
{% endif %}

Let’s try this, I can’t debug so I don’t know for sure, but I think this should work. If you replace the last 4 lines of your code with the following:

<form method="post" action="/cart/add" align="center">
    <input type="hidden" name="id" value="{{ product.variants.first.id }}" />
    <input type="submit" value="Aggiungi al carrello" class="btn" {% if product.selected_or_first_available_variant.available == false %}
        disabled{% endif %}/>
</form>

Thanks a lot, you are the best!!

great, I am glad we got there finally!

Is it possible to do the same things for variant unaivalable products?