I have implemented an ajax add to cart button on my woocommerce shop
echo sprintf( '<button type="submit" data-product_id="%s" data-product_sku="%s" data-quantity="1" class="%s button product_type_simple">%s</button>', esc_attr( $product->id ), esc_attr( $product->get_sku() ), esc_attr( $link['class'] ), esc_html( $link['label'] ) );
The button is working just fine and after clicking, the product is added to the cart And im using "added_to_cart" java-script hook to display the mini-cart as s a popup to the user.
only now 2 problems occur
1st problem : if i click the button again , instead of adding the item to the current quantity the page is refreshed and im getting the woocommerce message "you already have this item in your cart"
2nd and more crucial when im navigating directly to the "cart" page i don't see the item in the cart , if i refresh the cart page again , the item magically appears ...
Any thoughts ?