Replace “Add to cart” 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 aren't currently for sale, or for products that are made to order.

Sectioned and non-sectioned themes

Steps for Sectioned themes

Select your theme

The steps for this customization vary depending on whether you are using the Narrative theme or another free theme made by Shopify. Click the button for your theme before following the instructions below:

Steps for 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.

Steps:

  1. From your Shopify admin, go to Online Store > Themes.
  2. Find the theme you want to edit, click the button to open the actions menu, and then click Edit code.
  3. In the Templates directory, click Add a new template.
  4. Create the product template:
    • From the drop-down menu, select product.
    • Name your template requires-contact.
    • Click Create 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>
  1. 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 more 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 %}
  1. Click Save.

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

  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:
Please <a href="mailto:{{ shop.email }}">contact us</a> if you are
interested in this product.
  1. 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.
  5. Find the closing </form> tag in the file. On a new line below the closing </form> tag, paste the code for the contact form.
  6. 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"></div>

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

</div>
  1. 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, go to 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 Online Store, choose your new requires-contact template from the Theme template drop-down.
  4. Click Save.

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

Ready to start selling with Shopify?Try it free