How to fix a non-responsive Shopify checkout button

Last updated:

Home » Articles » Shopify » How to fix a non-responsive Shopify checkout button

Have you been testing your Shopify checkout button regularly? What if your Shopify checkout button is 

  • reloading the same page, 
  • not responding to clicks, 
  • or not redirecting to the checkout page, 

It’s crucial to address the issue immediately. After all, how can you make sales if customers can’t complete their purchases? To assist you, this guide offers a temporary fix for when your Shopify checkout button isn’t functioning correctly.

How to fix checkout button in Shopify steps by steps

Work on Shopify liquid 

We won’t keep you waiting. Here’s how to fix the checkout button in Shopify step by step.

First, access your Shopify theme code:

1. Log in to your Shopify account.

2. Navigate to Online Store > Themes.

3. Click on “Actions” next to your current theme.

4. Select “Edit Code.”

Next, locate the checkout button:

1. Open the `cart.liquid` file. This file typically contains the code for your cart button.

2. Use the search function to find your checkout button. Look for `id=”checkout”` or relevant class names associated with the button.

Now, modify the checkout button code with these actions: 

Add comment tags around the existing button code. Here’s an example of how to do this:

<!--
<button type="submit" id="checkout" class="cart__checkout-button button" name="checkout" {% if cart == empty %} disabled{% endif %} form="cart">
    {{ 'sections.cart.checkout' | t }}
</button>
-->

Below the commented-out button code, add the new implementation:

{%- if cart != empty -%}
  <form action="{{ routes.cart_url }}/checkout" method="post" id="cart-form">
    <button 
      type="submit" 
      name="checkout" 
      class="cart__checkout-button button"
      {% if cart.items.size == 0 %}disabled{% endif %}
      data-cart-submit
    >
      {{ 'sections.cart.checkout' | t }}
      <span class="loading-spinner hidden">
        {% render 'icon-spinner' %}
      </span>
    </button>
    
    {% if cart.attributes != empty %}
      {% for attribute in cart.attributes %}
        <input type="hidden" name="attributes[{{ attribute.first }}]" value="{{ attribute.last }}">
      {% endfor %}
    {% endif %}
  </form>
{%- endif -%}

Remember to replace `your-store-name` with your actual Shopify store name.

To maintain consistent styling, copy the class attributes from the original button to the new link:

  <a href="https://your-store-name.myshopify.com/checkout" class="cart__checkout-button button">
      {{ 'sections.cart.checkout' | t }}
  </a>

If you encounter any issues or need further assistance while following our instructions, reach out to our Shopify support, and we’ll provide the answers right away.

🌊 You won’t get lost in the data from your website. We’ll explain what your data means and how to use it to get more visitors and sales. Get a quote →

Work on theme’s code 

If the above solutions don’t work, you may need to dig deeper into your theme’s code. Add this same code snippet to your theme’s JavaScript file or within a <script> tag in your product template.

document.addEventListener('DOMContentLoaded', function() {
  const cartForm = document.getElementById('cart-form');
  const checkoutButton = document.querySelector('[data-cart-submit]');
  const loadingSpinner = checkoutButton?.querySelector('.loading-spinner');

  if (cartForm && checkoutButton) {
    cartForm.addEventListener('submit', async function(event) {
      event.preventDefault();
      
      try {
        checkoutButton.disabled = true;
        loadingSpinner?.classList.remove('hidden');

        const cartResponse = await fetch('/cart.js');
        const cartData = await cartResponse.json();
        
        if (!cartData.items || cartData.items.length === 0) {
          throw new Error('Cart is empty');
        }

        window.location.href = '/checkout';
      } catch (error) {
        console.error('Checkout error:', error);
        const errorMessage = document.createElement('div');
        errorMessage.classList.add('cart-error');
        errorMessage.textContent = 'Unable to proceed to checkout. Please try again.';
        cartForm.insertBefore(errorMessage, checkoutButton);
      } finally {
        checkoutButton.disabled = false;
        loadingSpinner?.classList.add('hidden');
      }
    });
  }
});

Note: Important Warning

Please read before proceeding:

This method requires modifying your theme’s code, which could potentially damage your site’s functionality if not implemented correctly.

If you’re not confident with code modifications, it’s recommended to:

  1. Contact a Shopify expert
  2. Reach out to your theme developer
  3. Work with a professional developer
  4. Use Shopify’s support services

FAQ

Q: What if I don’t see the changes reflected on my store after editing the code?
A: If changes are not reflected, try clearing your browser cache or checking the store in an incognito window to see if the updates are visible.

Q: How do I know if a third-party app is conflicting with my checkout button?
A: To identify conflicts, disable third-party apps one by one and test the checkout button after each change to see if the issue is resolved.

Q: Is there a way to track if customers are encountering issues with the checkout button?
A: Yes, you can use tools like Google Analytics or Shopify’s built-in reports to track checkout behavior and identify any drop-off points.

Wave

Enjoy our articles? Join our free list and get more.

Sign Up

Book Discovery Call