Skip to content

Instantly share code, notes, and snippets.

@jorpdesigns
Created July 15, 2021 11:57
Show Gist options
  • Select an option

  • Save jorpdesigns/68167d08bfbc8af236e25964ac12f031 to your computer and use it in GitHub Desktop.

Select an option

Save jorpdesigns/68167d08bfbc8af236e25964ac12f031 to your computer and use it in GitHub Desktop.
Snippet to add "Continue Shopping" button on WooCommerce Cart page
<?php
add_action( 'woocommerce_before_cart_table', 'add_continue_shopping_button_to_cart' );
function add_continue_shopping_button_to_cart() {
$shop_page_url = get_permalink( woocommerce_get_page_id( 'shop' ) );
if ( WC()->cart->get_cart_contents_count() > 0 ) {
echo '<div class="woocommerce-message">';
echo 'Would you like to add some more products? <a href="' . $shop_page_url . '" class="add-item button alt">Continue Shopping</a>';
echo '</div>';
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment