Created
February 26, 2018 10:00
-
-
Save acanza/eb08a2d3da75ddfd08508c8a44072a7b to your computer and use it in GitHub Desktop.
Oculta el precio del producto cuando este tiene coste 0
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
| // 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