Change the WooCommerce Shop Page URL

You can change the WooCommerce shop URL with a filter that WooCommerce provides, this can be helpful especially if you have a one product based shop and you want your users to return to that product and not the default shop page URL.

The filter to use is aptly named – woocommerce_return_to_shop_redirect

add_filter( 'woocommerce_return_to_shop_redirect', 'st_woocommerce_shop_url' );
/**
 * Redirect WooCommerce Shop URL
 */

function st_woocommerce_shop_url(){

return site_url() . '/product/my-product/';

}

So in the above code the filter is run and returns the main site URL with site_url() and then adds on a slug of the page you want – above it goes to a particular product, or you could not use site_url() and just hard code the absolute URL in quotes.

1 Comment

  1. Mary Jo on January 22, 2018 at 10:02 pm

    i cannot get this to work! i’m using woocommerce version 3.2.6 with the jupiter theme, and using code snippets rather than adding the code to the functions.php file. i’ve used code snippets for many things with no issues. any ideas i can’t get this one to work?

Leave a Comment





%d bloggers like this: