Adding a WAIT or JQuery delay() / settimeout function after checkout button is clicked but before...

Adding a WAIT or JQuery delay() / settimeout function after checkout button is clicked but before...

afcompany
Shopify Partner
16 0 9

I am wanting to do 1 of 2 things. Trying to stop getting the attached error. It happens 50% of the time, but I can always get it to occur. When I click checkout from the cart page, this shows up. It's a 202 error code. When I get to this page error, I can do a refresh and can proceed just fine. 

So this tells me that the page is trying to process before all the content is loaded.

 

So I was wanting to try (1) somehow adding a liquid WAIT function before the process that occurs that is trying to display the checkout page or (2) somehow add a auto-refresh if that error code initiates. 

 

That error page that is displayed doesn't seem to be found in my EDIT CODE section of the theme, so I am perplexed. It appears it's trying to create and /invoice/, which I can't find in the EDIT CODE display. 

 

I would appreciate any input, feedback, solutions!

afcompany_0-1685023625686.png

 

 

Replies 2 (2)

NomtechSolution
Astronaut
1245 113 159
  1. Ensure all content is loaded before processing: To prevent the error related to content not being fully loaded, you can use JavaScript to wait for the page to be fully loaded before executing any processes. You can achieve this by wrapping the checkout process code in a DOMContentLoaded event listener. Here's an example:

 

document.addEventListener("DOMContentLoaded", function() {
  // Your checkout process code goes here
});

 

  1. Implement automatic refresh: If the error persists, you can consider implementing an automatic refresh as a temporary workaround. This can be done using JavaScript's setTimeout function to refresh the page after a certain interval. Here's an example:

 

setTimeout(function() {
  location.reload(); // Refresh the page
}, 5000); // Refresh after 5 seconds (adjust as needed)
​

 

afcompany
Shopify Partner
16 0 9

This is great information. I am trying to find that code that executes after the checkout button is clicked. It's not easy to follow, it also seems it's maybe using an API on checkout? The url where the error occurs is oursitename.com/546496835/invoices/546513216584651 - so I am trying to find where that page is generated, as I am not finding anything in the code. I'm fishing through all the EDIT CODE pages to try and find this reference.