A freelance client hired me a while ago to display a “Continue Shopping” button on the Single Product Page, next to the Add to Cart. A simple way to send their users back to where they were coming from without clicking the “previous” button on the browser 🙂

Here’s how it’s done, featuring an awesome WordPress function called “wp_get_referer()”!

Continue Shopping button @ WooCommerce Single Product Page

PHP Snippet: “Continue Shopping” Button @ Single Product Page – WooCommerce

 

/**
 * @snippet       Continue Shopping button @ Single Product Page
 * @how-to        Get CustomizeWoo.com FREE
 * @sourcecode    https://businessbloomer.com/?p=72772
 * @author        Rodolfo Melogli
 * @testedwith    WooCommerce 3.1.1
 */

add_action( 'woocommerce_single_product_summary', 'bbloomer_continue_shopping_button', 31 );

function bbloomer_continue_shopping_button() {
  if ( wp_get_referer() ) echo '<a class="button continue" href="' . wp_get_referer() . '">Continue Shopping</a>';
}

Share:

Leave a Reply