Add the Ability to stop purchase

If you want to keep your store running but you don’t want to offer checkout functionality, you can pause your store in the Shopify Admin (under Themes> Customize > Product Pages). This will make your store “dormant”, which disables checkout. To do this, you simply have to write this is to your theme.

Editing your theme code to add this feature

  • In the Section directory, open the product-template.liquid and find add to cart button, the cart button looks like the following in the debut theme and other themes contains this code <button type="submit" name="add" :
<div class="product-form__item product-form__item--submit{% if section.settings.enable_payment_button %} product-form__item--payment-button{% endif %}{% if product.has_only_default_variant %} product-form__item--no-variants{% endif %}">
              <button type="submit" name="add"
                {% unless current_variant.available %} aria-disabled="true"{% endunless %}
                aria-label="{% unless current_variant.available %}{{ 'products.product.sold_out' | t }}{% else %}{{ 'products.product.add_to_cart' | t }}{% endunless %}"
                class="btn product-form__cart-submit{% if section.settings.enable_payment_button %} btn--secondary-accent{% endif %}"
                data-add-to-cart>
                <span data-add-to-cart-text>
                  {% unless current_variant.available %}
                    {{ 'products.product.sold_out' | t }}
                  {% else %}
                    {{ 'products.product.add_to_cart' | t }}
                  {% endunless %}
                </span>
                <span class="hide" data-loader>
                  {% include 'icon-spinner' %}
                </span>
              </button>
              {% if section.settings.enable_payment_button %}
                {{ form | payment_button }}
              {% endif %}
</div>

 

  • Add this code above of the button code {% unless section.settings.disable_cart %} and add this {% endunless %} right after the button code.
  • In the same file find the {% schema %} and locate settings, go to the ] in the settings and add the following code right above the ] :
,
    {
      "type": "checkbox",
      "id": "disable_cart",
      "label": "Disable Purchase",
      "default": false
    }

 

  • Congrats you’ve completed the coding part. Now it’s available in the Themes>Customize>product pages. Now you can enable or disable the Add to cart button which will stop purchasing in your store

Enjoy this feature. 🙂

cart search