Skip to content

Instantly share code, notes, and snippets.

@acanza
Created February 26, 2018 10:00
Show Gist options
  • Select an option

  • Save acanza/eb08a2d3da75ddfd08508c8a44072a7b to your computer and use it in GitHub Desktop.

Select an option

Save acanza/eb08a2d3da75ddfd08508c8a44072a7b to your computer and use it in GitHub Desktop.
Oculta el precio del producto cuando este tiene coste 0
// Oculta el precio del producto cuando este tiene coste 0
if ( in_array( 'woocommerce/woocommerce.php', get_option( 'active_plugins' ) ) && version_compare( WC()->version , '3.0.0', '>' ) ){
add_filter( 'woocommerce_get_price_html', 'hide_price_for_free_products' );
function hide_price_for_free_products( $price ) {
global $product;
if ( !$product->is_type( 'variable' ) && (0 == $product->get_price() ) ) {
return '';
}
if ( $product->is_type( 'variable' ) && ( 0 == $product->get_variation_price() ) && ( 0 == $product->get_variation_price( 'max' ) ) ) {
return '';
}
return $price;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment