Pptinyint
Pptinyint

Reputation: 11

How to stop Ajax cart button functionality from add to cart button

Plugin is WP Configurator Pro i want that the ajax add to cart button redirect to cart page. Tried this and many other examples but did not work add_action( 'wp_footer', 'trigger_for_ajax_add_to_cart' ); function trigger_for_ajax_add_to_cart() { ?> <script type="text/javascript"> (function($){ $( ".js-wpc-submit-cart-form" ).trigger( "click" ); window.location = "cart link"; })(jQuery); </script> <?php }

Upvotes: 0

Views: 355

Answers (1)

Pptinyint
Pptinyint

Reputation: 11

I have solved this to my own here are the steps so first I had to Disabled Ajax Call from WooCommerce

function disable_woo_cart() {   
   wp_dequeue_script( 'wc-cart-fragments');
} 
add_action( 'wp_enqueue_scripts', 'disable_woo_cart', 11 );

and after that I write this redirection code

function add_to_cart_redirect() {
    global $woocommerce;
    return $woocommerce->cart->get_cart_url();
}
add_filter( 'woocommerce_add_to_cart_redirect', 'add_to_cart_redirect' );

Upvotes: 0

Related Questions