Created
April 22, 2022 07:57
-
-
Save bradleysa/e2574b193032d3be40cd5b0b3c78b10f to your computer and use it in GitHub Desktop.
WC: Custom Low Stock message
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
/* 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 = "Supplies are running low! Get your jam!"; | |
} | |
$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); | |
/** https://support.woothemes.com/hc/en-us/articles/203178095-How-to-display-Low-Stock-instead-of-Only-x-left-in-stock-on-product-page **/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment