Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Different stock status names for your WooCommerce product detail page
<?php
/*
Using this function you can use different values on the frontend while keeping the original strings or translations.
How to use:
Place the PHP code below into the functions.php file from your WordPress child theme.
If you like, change the strings inside the quotes for the $status variables.
The action hook will place the information below the add to cart button (based on the original WooCommerce template files).
*/
function add_stock_status_info() {
global $product;
$stock_status = $product->get_stock_status();
switch ($stock_status) {
case 'instock':
$status = 'Uit voorraad leverbaar';
break;
case 'onbackorder':
$status = 'Levertijd 3-5 werkdagen';
break;
case 'outofstock':
$status = 'Niet meer leverbaar';
break;
default:
$status = '';
break;
}
if ($status) echo '
<div class="voorraad">'.$status.'</div>';
}
add_action('woocommerce_single_product_summary', 'add_stock_status_info', 30);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.