Redirect to Checkout only for certain items
-
After many many hours i am stumped on how to achieve this, our site sells products and also memberships and donations. We want products to do the default action of staying on the product page but if its a donation or membership we want it to go directly to checkout.
I have been working with the add_to_cart_redirect filter, inside the function I have used is_page(‘donation’);, has terms product_cat, global $post, also tried to dig through the global $woocommerce to get some sort of variable to change the redirect to cart for only certain products.
add_filter('add_to_cart_redirect', 'custom_add_to_cart_redirect'); function custom_add_to_cart_redirect() { return get_permalink(get_option('woocommerce_checkout_page_id')); // Replace with the url of your choosing }
Anyone run into this before and have some pointers?
function redirect_to_checkout() { global $woocommerce,$post; if( has_term( 'membership-donations', 'product_cat', $post->ID ) ){ $checkout_url = get_permalink(get_option('woocommerce_checkout_page_id')); return $checkout_url; }; }
Thanks!
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘Redirect to Checkout only for certain items’ is closed to new replies.