Created
July 14, 2017 20:32
-
-
Save luizbills/19385782f4585dc5511dbf2d7f25b967 to your computer and use it in GitHub Desktop.
Mostrar o texto 'Grátis' quando produto tiver preço R$ 0,00 (zero reais)
This file contains hidden or 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 | |
/** | |
* @version 1.0.0 | |
* @author Luiz Paulo Bills <[email protected]> | |
*/ | |
add_filter( 'woocommerce_get_price_html', 'lpb_wc_display_free_price', 99, 2 ); | |
function lpb_wc_display_free_price ( $price, $product ) { | |
if ( $product->get_price() == 0 ) { | |
$label = 'Grátis'; | |
$template = '<span class="woocommerce-Price-amount amount free">%s</span>'; | |
return sprintf( $template, __( $label, 'lpb-wc-display-free-price' ) ); | |
} | |
return $price; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
top funciona muito bem! tem para o valor do carrinho?