Last active
June 4, 2020 06:49
-
-
Save Oscar-Abad-Folgueira/32cc02217ff4071af4d5a726251d2e10 to your computer and use it in GitHub Desktop.
WooCoomerce Snippet - Ocultar precios a usuarios no registrados
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 | |
/** | |
* @snippet WooCoomerce Snippet - Ocultar precios a usuarios no registrados | |
* @author Oscar Abad Folgueira | |
* @author_url https://www.oscarabadfolgueira.com | |
* @snippet_url https://www.oscarabadfolgueira.com/ocultar-precios-a-usuarios-no-registrados-en-woocommerce | |
*/ | |
add_filter( 'woocommerce_variable_sale_price_html', 'update_price_html', 10, 2 ); | |
add_filter( 'woocommerce_variable_price_html', 'update_price_html', 10, 2 ); | |
add_filter( 'woocommerce_get_price_html','update_price_html', 999, 2 ); | |
function update_price_html( $html, $product ) { | |
if(!is_user_logged_in()) { // Si el usuario no está logueado | |
add_filter( 'woocommerce_is_purchasable', '__return_false'); | |
$html = "Necesitas estar registrado para ver los precios"; | |
return $html; | |
} else { | |
return $html; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment