We've implemented shipping conditions before into our client's cart to show shipping (after they enter their zip code) which have worked fine. But on a new project, we built out some logic and implemented it in the cart but the cart now simply hangs for a long period of time before returning a result. It's really hit or miss. Sometimes it works within a reasonable time frame and sometimes the cart takes minutes to return a result (if at all).
I'm not sure if the issue is on our end or on the server's end.
Here's the code: https://gist.github.com/smashstack-aeros/1805ee89364be176e0b9
Is there anything that stands out that's problematic with this code?