Woocommerce: Auto-redirect to cart after adding product from category

user1810236 picture user1810236 · Nov 8, 2012 · Viewed 42.4k times · Source

http://www.passgotutoring.com/shop/product-category/ucla/ucla-14a/

I am trying to get a auto redirect towards WP_Cart to happen as soon as a client "adds to cart" one of our classes that are located on the left.

Most of my clients buy a product, pay for it right away so I dont need to really have them keep shopping or anything.

I have tried inputting this code in to my function.php of my theme with no luck when I wanted them to go to their checkout directly.

add_action('init','woocommerce_go_to_checkout_action',30);
function woocommerce_go_to_checkout_action(){
if ( empty( $_REQUEST['add-to-cart'] ) || sizeof($woocommerce->cart->get_cart())==0) )
    return; wp_safe_redirect( $woocommerce->cart->get_checkout_url() );
}

Any ideas on how I could get it to work? 1. I would like it to go to cart instead of checkout. 2. I tried the checkbox method on the catalog page and it did not work.

Answer

Andrew picture Andrew · Feb 11, 2014

In WooCommerce 3.x you'll find this setting under:

WooCommerce > Settings > Products > General > Add to cart behaviour > [✓] Redirect to the cart page after successful addition


In WooCommerce 2.3 you'll find this setting under:

WooCommerce > Settings > Products > Display > [✓] Redirect to the cart page after successful addition


In WooCommerce 2.1 you'll find this setting under:

WooCommerce > Settings > Products > [✓] Redirect to the cart page after successful addition