My client wants to place a “return to shop” button on single product pages in WooCommerce that leads back to the previous page and not the main shop page.
I have explained that all browsers have back buttons but they are dead set on having this button. I’ve even mentioned activating breadcrumbs but they don’t like those either.
How can I achieve That. Any help is greatly appreciated.
Advertisement
Answer
You will get the category id by using bellow code and then add if condition to show the like
$product_category = wp_get_post_terms( $post->ID, 'product_cat' );