Replace the Add to cart button with a contact link

You can replace the Add to cart button with an email link or a contact form. For example, you might want to replace the Add to cart button for products that are not currently for sale, or for products that are made to order.

A polo shirt product page with a 'Contact us' link

Sectioned and non-sectioned themes

Create a new product template

To replace the Add to cart button for a product, you will need to create a custom product template for that product.

  1. Find the theme you want to edit, click Actions, and then click Edit code.

  2. In the Templates directory, click Add a new template.

  3. Create the product template:
    a. From the drop-down menu, select product.
    b. Name your template requires-contact.
    c. Click Create template.

    'Add a new template' dialog showing the new 'requires-contact' template
  4. Find the following code:

    
    {% section 'product-template' %}
    
    

    Replace it with:

    
    {% section 'product-template-requires-contact' %}
    
    

    This code will link your new template with a new product section that you will create in the next steps.

  5. Click Save.

Create a new product section

  1. In the Sections directory, click Add a new section.

  2. Create the section:
    a. Name your new section product-template-requires-contact.
    b. Click Create section.

  3. Delete all of the default code in the section file, so that the file is empty.

  4. In the Sections directory, click product-template.liquid. Copy all the content of the file to your clipboard. Return to your new product-template-requires-contact.liquid section, and paste the code into the file.

  5. Click Save.

Hide the Add to cart button

  1. In your new product-template-requires-contact.liquid section file, find the HTML code for the Add to cart button of your product page. You can search for the word cart.

    The code for the Add to cart button varies from theme to theme. Look for an <input> or <button> tag with text like Add to cart, AddToCart, or add-to-cart.

    For Debut, the Add to cart button code looks like this:

    <button type="submit" name="add" id="AddToCart-{{ section.id }}" {% unless current_variant.available %}disabled="disabled"{% endunless %} class="btn product-form__cart-submit{% if product.options.size == 1 and product.variants[0].title == 'Default Title' %} product-form__cart-submit--small{% endif %}">
      <span id="AddToCartText-{{ section.id }}">
        {% unless current_variant.available %}
          {{ 'products.product.sold_out' | t }}
        {% else %}
          {{ 'products.product.add_to_cart' | t }}
        {% endunless %}
      </span>
    </button>
    
  2. When you find the code, wrap it in Liquid {% comment %} and {% endcomment %} tags. This will stop the code from being shown on your store, but will let you easily put it back if you want to change your new template later.

    For Debut, the modified code would look like this:

    {% comment %}
    <button type="submit" name="add" id="AddToCart-{{ section.id }}" {% unless current_variant.available %}disabled="disabled"{% endunless %} class="btn product-form__cart-submit{% if product.options.size == 1 and product.variants[0].title == 'Default Title' %} product-form__cart-submit--small{% endif %}">
      <span id="AddToCartText-{{ section.id }}">
        {% unless current_variant.available %}
          {{ 'products.product.sold_out' | t }}
        {% else %}
          {{ 'products.product.add_to_cart' | t }}
        {% endunless %}
      </span>
    </button>
    {% endcomment %}
    
  3. Click Save.

Now that you have hidden the Add to cart button, you can add the content you want to show instead.

You can add an email link that will open the customer's default email program and enter your store's customer-facing email address as the recipient. To add an email link:

  1. On a new line below the Liquid {% endcomment %} tag that you added in the last step, add the HTML code for an email link:

    <p>Please <a href="mailto:{{ shop.email }}">contact us</a> if you are interested in this product.</p>
    
  2. Click Save.

Contact form

You can add a contact form to your new product template by copying the code from your theme's contact page template. To add a contact form:

  1. In the Templates directory, click page.contact.liquid.

  2. Find the Liquid {% form 'contact' %} tag in the file.

  3. Copy all of the code from the Liquid {% form 'contact' %} tag down to the Liquid {% endform %} tag. Include the Liquid form tags in the code that you copy.

  4. Return to your new product-template-requires-contact.liquid file in the Sections directory. On a new line below the Liquid {% endcomment %} tag that you added in the previous steps, paste the code for the contact form.

  5. The next step is to wrap the code that you just pasted in HTML div tags. The class attribute included in the div tag code will ensure that your contact form renders correctly on the page.

    On a new line above {% form 'contact' %}, paste the following code:

    <div class="form-vertical">
    

    On a new line below {% endform %}, paste the following code:

    </div>
    
  6. Click Save.

Assign your new template to a product

Now that the template is finished, you can assign it to all of the products for which you want to hide the Add to cart button.

  1. From your Shopify admin, click Products.

  2. Click the name of a product that you want to hide the Add to cart button on.

  3. On the product page of your Shopify admin, under Theme templates, choose your new requires-contact template from the Template suffix drop-down.

  4. Click Save.

Repeat these steps for each product to which you want to add your new template.

Create a new product template

To replace the Add to cart button for a product, you will need to create a custom product template for that product.

  1. Find the theme you want to edit, click Actions, and then click Edit code.

  2. In the Templates directory, click Add a new template.

  3. Create the product template:
    a. From the drop-down menu, select product.
    b. Name your template requires-contact.
    c. Click Create template.

    'Add a new template' dialog showing the new 'requires-contact' template

Hide the Add to cart button

  1. In your new product.requires-contact.liquid file, find the HTML code for the Add to cart button. You can search for the word cart.

    The code for the Add to cart button varies from theme to theme. Look for an <input> or <button> tag with text like Add to cart, AddToCart, or add-to-cart.

    For Debut, the Add to cart button code looks like this:

    <button type="submit" name="add" id="AddToCart-{{ section.id }}" {% unless current_variant.available %}disabled="disabled"{% endunless %} class="btn product-form__cart-submit{% if product.options.size == 1 and product.variants[0].title == 'Default Title' %} product-form__cart-submit--small{% endif %}">
      <span id="AddToCartText-{{ section.id }}">
        {% unless current_variant.available %}
          {{ 'products.product.sold_out' | t }}
        {% else %}
          {{ 'products.product.add_to_cart' | t }}
        {% endunless %}
      </span>
    </button>
    
  2. When you find the code, wrap it in Liquid {% comment %} and {% endcomment %} tags. This will stop the code from being shown on your store, but will let you easily put it back if you want to change your new template later.

    For Debut, the modified code would look like this:

    {% comment %}
    <button type="submit" name="add" id="AddToCart-{{ section.id }}" {% unless current_variant.available %}disabled="disabled"{% endunless %} class="btn product-form__cart-submit{% if product.options.size == 1 and product.variants[0].title == 'Default Title' %} product-form__cart-submit--small{% endif %}">
      <span id="AddToCartText-{{ section.id }}">
        {% unless current_variant.available %}
          {{ 'products.product.sold_out' | t }}
        {% else %}
          {{ 'products.product.add_to_cart' | t }}
        {% endunless %}
      </span>
    </button>
    {% endcomment %}
    
  3. Click Save.

Now that you have hidden the Add to cart button, you can add the content you want to show instead.

You can add an email link that will open the customer's default email program and enter your store's customer-facing email address as the recipient. To add an email link:

  1. On a new line below the Liquid {% endcomment %} tag that you added in the last step, add the HTML code for an email link:

    <p>Please <a href="mailto:{{ shop.email }}">contact us</a> if you are interested in this product.</p>
    
  2. Click Save.

Contact form

You can add a contact form to your new product template by copying the code from your theme's contact page template. To add a contact form:

  1. In the Templates directory, click page.contact.liquid.

  2. Find the Liquid {% form 'contact' %} tag in the file.

  3. Copy all of the code from the Liquid {% form 'contact' %} tag down to the Liquid {% endform %} tag. Include the Liquid form tags in the code that you copy.

  4. Return to your new product.requires-contact.liquid file in the Templates directory. On a new line below the Liquid {% endcomment %} tag that you added in the previous steps, paste the code for the contact form.

  5. The next step is to wrap the code that you just pasted in HTML div tags. The class attribute included in the div tag code will ensure that your contact form renders correctly on the page.

    On a new line above {% form 'contact' %}, paste the following code:

    <div class="form-vertical">
    

    On a new line below {% endform %}, paste the following code:

    </div>
    
  6. Click Save.

Assign your new template to a product

Now that the template is finished, you can assign it to all of the products for which you want to hide the Add to cart button.

  1. From your Shopify admin, click Products.

  2. Click the name of a product that you want to hide the Add to cart button on.

  3. On the product page of your Shopify admin, under Theme templates, choose your new requires-contact template from the Template suffix drop-down.

  4. Click Save.

Repeat these steps for each product to which you want to add your new template.

Want to discuss this page?

Visit the Shopify Community