Skip to content

Instantly share code, notes, and snippets.

@luizbills
Created July 14, 2017 20:32
Show Gist options
  • Save luizbills/19385782f4585dc5511dbf2d7f25b967 to your computer and use it in GitHub Desktop.
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)
<?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;
}
@ositecerto
Copy link

top funciona muito bem! tem para o valor do carrinho?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment