Last active
November 24, 2016 01:29
-
-
Save pablo-sg-pacheco/326c933ded878d943229 to your computer and use it in GitHub Desktop.
Replaces product price by out of stock message in case a variable product is out of stock (Woocommerce)
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 | |
//Replaces product price by out of stock message in case a variable product is out of stock (optional) | |
add_action('woocommerce_before_single_product_summary',function(){ | |
if(is_product()){ | |
global $product; | |
if(!$product->is_in_stock()){ | |
remove_action('woocommerce_single_variation','woocommerce_single_variation'); | |
remove_action('woocommerce_single_product_summary','woocommerce_template_single_price'); | |
add_action('woocommerce_single_product_summary',function(){ | |
?> | |
<p class="stock out-of-stock"><?php _e( 'This product is currently out of stock and unavailable.', 'woocommerce' ); ?></p> | |
<?php | |
}); | |
} | |
} | |
}); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment