php – Change WooCommerce Add to Cart Button to use ninja forms pop up


I found this code which replaces the text but I am unclear on how to change the function of the WooCommerce add to cart button.

The ideal situation is that when someone clicks the Add to Cart button for all products/any type of product, it will then trigger a ninja forms pop up. I know how to make the ninja forms pop up code, I am just not sure how to edit this filter or create a filter to change what clicking the button does.

// To change add to cart text on single product page
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_custom_single_add_to_cart_text' ); 
function woocommerce_custom_single_add_to_cart_text() {
    return __( 'Buy Now', 'woocommerce' ); 
How to&Answers:

Leave a Reply

Your email address will not be published. Required fields are marked *