Skip to content

Instantly share code, notes, and snippets.

@BurlesonBrad
Last active September 2, 2016 16:23
Show Gist options
  • Save BurlesonBrad/c2beabe16b47792095e032a1e209b053 to your computer and use it in GitHub Desktop.
Save BurlesonBrad/c2beabe16b47792095e032a1e209b053 to your computer and use it in GitHub Desktop.
Change stock text ~ there's TWO of them (not just one!) https://bradgriffin.me
<?php
/**
* Plugin Name: Wayne Changes Text Field
* Plugin URI: https://bradgriffin.me
* Description: Changes the stock text - BOTH of them. Not just one!
* Version: 1
* Author: Brad
* Author URI: https://bradgriffin.me
* Requires at least: 4.6
* Tested up to: 4.6
**/
/* USE THIS ---> https://wordpress.org/plugins/code-snippets | Then GoTo Snippets --> Add New > Copy & Paste the code below */
/* Using plugin mentioned above ^^^ remember to copy/past the code BELOW these commnents which will remove the opening <?php tag */
/* or via FTP, drop this file into the /plugins folder right next to all the other plugins! #whoop! */
/* Or add the code BELOW to your child themes functions.php */
/* See the lines 24 and 28? Right between the 'single quote' change those words to whatever you want */
/* If you're using WooCommerce to HIRE PEOPLE and (for whatever reason) must have the Manage Stock feature selected */
/* ....then perhaps something like 'Hire Now' would be a suitable alternative for 'Available' and 'Currently Booked' could replace 'Sold Out' */
/* Either way, this smaller snippet is much leaner, cleaner, than a completely new (HUGE) plugin */
add_filter( 'woocommerce_get_availability', 'wcs_custom_get_availability', 1, 2);
function wcs_custom_get_availability( $availability, $_product ) {
if ( $_product->is_in_stock() ) {
$availability['availability'] = __('Available!', 'woocommerce'); //Change the words between the 'single quotes' //
}
if ( ! $_product->is_in_stock() ) {
$availability['availability'] = __('Sold Out', 'woocommerce'); //Change the words between the 'single quotes' //
}
return $availability;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment