Last active
July 14, 2017 14:24
-
-
Save luizbills/c1dc8e653a3bd246527de40cc54b893e to your computer and use it in GitHub Desktop.
Mostra uma notificação informando quanto precisa comprar a mais para ter frete grátis
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
<?php | |
add_action( 'woocommerce_check_cart_items', 'lpb_free_shipping_cart_notice' ); | |
function lpb_free_shipping_cart_notice () { | |
if ( ! is_cart() ) return; | |
// mude o valor 150 para o valor mínimo do frete grátis | |
$free_shipping_amount = 150; | |
// modelo da mensagem (não remova o "%s") | |
$message = 'Compre mais %s para ter frete grátis!'; | |
$cart_amount = WC()->cart->cart_contents_total; | |
$diff = $free_shipping_amount - $cart_amount; | |
if ( $diff > 0 ) { | |
wc_print_notice( sprintf( __( $message, 'lpb-free-shipping-cart-notice' ), wc_price( $diff ) ), 'notice' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment