Add Continue Shopping button to Single Product page, Cart page and Checkout page – paaljoachim

Found bradleysa’s original WooCommerce: Add Continue Shopping Button on Cart Page. Then found paaljoachim’s update in comments. Then altered paaljoachim’s code for my needs.

/* Add continue shopping button to Single product page, Cart page and Checkout page.
/* https://gist.github.com/bradleysa/7d1448253097784daf94?permalink_comment_id=4080401#gistcomment-4080401
/* Single product
/* https://www.businessbloomer.com/woocommerce-continue-shopping-button-single-product-page/
/* https://www.businessbloomer.com/woocommerce-visual-hook-guide-single-product-page/ */
add_action( 'woocommerce_after_add_to_cart_button', 'continue_shopping_button_to_single_product' );
function continue_shopping_button_to_single_product() {
 $shop_page_url = get_permalink( woocommerce_get_page_id( 'shop' ) );
 echo ' <a class="continue button" href="'.$shop_page_url.'">Continue Shopping</a>';
}
/* Cart
/* https://wpbeaches.com/add-continue-shopping-button-woo-commerce-cart-page/
/* https://www.tychesoftwares.com/woocommerce-cart-page-hooks-visual-guide-with-code-examples/ */
add_action( 'woocommerce_before_cart', 'continue_shopping_button_to_cart' );
function continue_shopping_button_to_cart() {
 $shop_page_url = get_permalink( woocommerce_get_page_id( 'shop' ) );
 echo ' <a class="continue button" href="'.$shop_page_url.'">Continue Shopping</a>';
}
/* Checkout
/* https://www.businessbloomer.com/woocommerce-visual-hook-guide-checkout-page/ 
/* https://gist.github.com/bradleysa/7d1448253097784daf94 */
add_action( 'woocommerce_before_checkout_form', 'continue_shopping_button_to_checkout', 1 );
function continue_shopping_button_to_checkout() {
 $shop_page_url = get_permalink( wc_get_page_id( 'shop' ) );
echo ' <a class="continue button" href="'.$shop_page_url.'">Continue Shopping</a>';
}

Leave a Comment

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

Scroll to Top