-
-
Save thanh4890/f178e8b2579a04f348dda3c9c0a9bceb to your computer and use it in GitHub Desktop.
WooCommerce: Show a notice throughout the store if the cart is empty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Tutorial: http://www.skyverge.com/blog/check-if-woocommerce-cart-is-empty/ | |
**/ | |
function skyverge_empty_cart_notice() { | |
if ( WC()->cart->get_cart_contents_count() == 0 ) { | |
wc_print_notice( __( 'Get free shipping if your order is over $60!', 'woocommerce' ), 'notice' ); | |
// Change notice text as desired | |
} | |
} | |
// Add to cart page | |
add_action( 'woocommerce_check_cart_items', 'skyverge_empty_cart_notice' ); | |
// Add to shop archives & product pages | |
add_action( 'woocommerce_before_main_content', 'skyverge_empty_cart_notice' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment