Skip to content

Instantly share code, notes, and snippets.

@MindyPostoff
Last active August 29, 2015 14:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MindyPostoff/9c7087e170f9cf327f26 to your computer and use it in GitHub Desktop.
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"
/* 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);
@logichub
Copy link

logichub commented Jun 3, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment