Hi,
I have been trying to redirect the user after he clicks the AddToCart Button to Checkout page.
I used the follwing code:
function my_custom_add_to_cart_redirect( $url ) {
$url = WC()->cart->get_checkout_url();
// $url = wc_get_checkout_url(); // since WC 2.5.0
return $url;
}
add_filter( ‘woocommerce_add_to_cart_redirect’, ‘my_custom_add_to_cart_redirect’ );
The redirect works for the AddToCart button on the Shop page, but not on the Single Page Product.
I mention that both (Redirect to the cart page after successful addition, Enable AJAX add to cart buttons on archives) are enabled.
I made some tests and with (Enable AJAX add to cart buttons on archives) disabled not even the AddToCart Button on the Shop Page does not redirect to Checkout.
I took a look with Inspect Element and I realized the code for the 2 buttons is different:
Shop Page AddToCart Button - class:“button product_type_simple add_to_cart_button ajax_add_to_cart”
Single Page Product AddToCart Button: “single_add_to_cart_button button alt”
It blows my mind how it is possible that 2 buttons that should do the same thing act in different ways.
I need a fix for this problem fast.