Last active
August 29, 2015 14:09
-
-
Save MindyPostoff/9c7087e170f9cf327f26 to your computer and use it in GitHub Desktop.
Display "Low Stock" Message on WooCommerce Product Page Instead of "Only # Left in Stock"
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
/* Change the 'Only # left in stock' message on the WooCommerce product page to | |
* simply show 'Low Stock'. | |
* Add to your theme's functions.php file | |
*/ | |
function custom_stock_totals($availability_html, $availability_text, $product) { | |
if (substr($availability_text,0, 4)=="Only") { | |
$availability_text = "Low Stock"; | |
} | |
$availability_html = '<p class="stock ' . esc_attr( $availability['class'] ) . '">' . esc_html( $availability_text ) . '</p>'; | |
return $availability_html; | |
} | |
add_filter('woocommerce_stock_html', 'custom_stock_totals', 20, 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am getting PHP Parse error after adding this snippet. Here is the error:
PHP Parse error: syntax error, unexpected 'function' (T_FUNCTION) in /www/wp-content/themes/notio-wp/functions.php on line 271