php - Woocommerce Add To Cart redirect to Checkout not working for product with variants -


i'm trying redirect people click on add cart button checkout page directly. add cart button adding product cart not redirecting @ all.

the code use working product no variations.

i'm using latest version of woocommerce 3.0.1.

//redirect checkout  add_filter ('add_to_cart_redirect', 'redirect_to_checkout');  function redirect_to_checkout() {     return wc()->cart->get_checkout_url(); } 

try this:

function add_to_cart_checkout_redirect() {       wp_safe_redirect( get_permalink( get_option( 'woocommerce_checkout_page_id' ) ) );       die(); } add_action( 'woocommerce_add_to_cart',  'add_to_cart_checkout_redirect', 11 ); 

Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -