Advertisement
srikat

Untitled

Sep 27th, 2020
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. // Woocommerce - Single product page notification
  2. add_action( 'woocommerce_share', 'custom_cart_notice' );
  3.  
  4. // Woocommerce - cart page notification
  5. add_action( 'woocommerce_before_cart_table', 'custom_cart_notice' );
  6.  
  7. // Kadence - side cart notificatin
  8. add_action( 'kadence-after-side-cart', 'custom_cart_notice' );
  9.  
  10. function custom_cart_notice() {
  11. $min_amount = 50; //change this to your free shipping threshold
  12.  
  13. $current = WC()->cart->subtotal;
  14.  
  15. if ( $current < $min_amount ) {
  16. $added_text = '<div class="woocommerce-message">Buy ' . wc_price( $min_amount - $current ) . ' worth products more to get free shipping<br/>';
  17. $return_to = wc_get_page_permalink( 'shop' );
  18. $notice = sprintf( '%s<a href="%s">%s</a>', $added_text, esc_url( $return_to ), 'Continue shopping</div>' );
  19. echo $notice;
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement