url redirection in woocommerce plugin

I want to know how can i add category base add to cart custom url redirection in woocommerce plugin.I am using this code but cant found how to redirect it to page.

* Redirect users after add to cart.
function my_custom_add_to_cart_redirect( $url ) {
if ( ! isset( $_REQUEST[‘add-to-cart’] ) || ! is_numeric( $_REQUEST[‘add-to-cart’] ) ) {
return $url;
$product_id = apply_filters( ‘woocommerce_add_to_cart_product_id’, absint( $_REQUEST[‘add-to-cart’] ) );
// Only redirect products that have the ‘t-shirts’ category
if ( has_term( ‘acid reflux’, ‘product_cat’, $product_id ) ) {
$url = WC()->cart->get_checkout_url();
return $url;
add_filter( ‘woocommerce_add_to_cart_redirect’, ‘my_custom_add_to_cart_redirect’ );

I am very thank full if someone help me out.Thanks

Read more here: url redirection in woocommerce plugin

Leave a Reply

Your email address will not be published. Required fields are marked *