Disable Checkout Button by Default to Allow Supertime to Collect Required Date or Time Data

Supertime by default is loaded using Shopify's script tag feature, which means we are loaded after the initial page is loaded, which can lead to Supertime being loaded slowly on slow connections especially if you happen to have a lot of scripts, apps or plugins in your storefront. If a date or time slot is required to checkout on your store, you may want to follow the steps below.

You may want to additionally restrict your customers from being able to checkout with the additional step of disabling your checkout button by default. Otherwise, your customers may be able to checkout before apps like Supertime have loaded in your theme's cart. 

You can update your theme to disable the checkout button by following the instructions below. Supertime will manage your checkout button's state once it is loaded in your cart. 

Method 1: Disable the button directly in your theme

Here's an example of how to disable your checkout button on the Debut theme:

  1. Visit your store's Theme settings.
  2. Click the Actions button and select Edit Code. Find your template file where the checkout button would be (e.g. in our case, it's in Sections > cart-template.liquid)
  3. Add disabled within the <button> or <input> field of the checkout button as an attribute. It should look like the following lines of code for the Debut theme:
  4.                 <input type="submit" name="checkout"
                      class="cart__submit btn btn--small-wide"
                      value="{{ 'cart.general.checkout' | t }}" disabled>
    	
  5. Click the Save button. Your checkout will be disabled by default, and Supertime will enable this button automatically, especially when your customers have provided required information for checkout.

Method 2: Insert a Snippet of Code to Disable Your Checkout Button on Load

Note: This method works if your theme has checkout buttons that have an attribute of name="checkout" and your checkout button is an <input> or <button> element, and your cart isn't a custom loaded via JavaScript.

Steps:

1. Copy and paste this snippet below - this snippet will search for your buttons and set the checkout buttons to be disabled on load before Supertime is loaded:

   <script>
     document.addEventListener("DOMContentLoaded", function(event) {
		var checkoutButtons = document.body.querySelectorAll('button[name="checkout"], input[name="checkout"]')
        checkoutButtons.forEach(function(button) {
			button.disabled = true;
		});
     });
  </script>

2. Visit your store's Theme settings.
3. Click the   Actions button and select Edit Code
4. Find your theme.liquid file if you have a cart that is present on all your pages.  
5. Paste the provided snippet immediately below your  <body> tag in that file.