How to make cart button work on a single click? Help!

So I set up a custom button to instantly add a shop item to the cart. The button is on a slideshow that I set up to pause on hover. The problem is, the first click apparently doesn’t do anything, you have to click twice to trigger the mini-cart. Is there a function I could add that would help? Here’s my code:


Thanks in advance, I really appreciate it!