Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Woocommerce - Single product page notification
- add_action( 'woocommerce_share', 'custom_cart_notice' );
- // Woocommerce - cart page notification
- add_action( 'woocommerce_before_cart_table', 'custom_cart_notice' );
- // Kadence - side cart notificatin
- add_action( 'kadence-after-side-cart', 'custom_cart_notice' );
- function custom_cart_notice() {
- $min_amount = 50; //change this to your free shipping threshold
- $current = WC()->cart->subtotal;
- if ( $current < $min_amount ) {
- $added_text = '<div class="woocommerce-message">Buy ' . wc_price( $min_amount - $current ) . ' worth products more to get free shipping<br/>';
- $return_to = wc_get_page_permalink( 'shop' );
- $notice = sprintf( '%s<a href="%s">%s</a>', $added_text, esc_url( $return_to ), 'Continue shopping</div>' );
- echo $notice;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement