Skip to content

Instantly share code, notes, and snippets.

@softiconic
Last active December 2, 2023 18:59
Show Gist options
  • Save softiconic/6b4be169c0e795dc1f29bf809ba2d9f3 to your computer and use it in GitHub Desktop.
Save softiconic/6b4be169c0e795dc1f29bf809ba2d9f3 to your computer and use it in GitHub Desktop.
In a WooCommerce product page, implement AJAX for the "Add to Cart" functionality.
//Remove old button which submiting form:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
//Add ajax-link from archive page to single product page:
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_loop_add_to_cart', 30 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment