Get HTML to show product stock.
Obtenir du HTML pour afficher le stock de produits.
$html, $availability['availability'], $product
Sortie :
@param WC_Product $product Product Object. @return string
// HTML stock personnalisé
add_filter('woocommerce_get_stock_html', 'html_stock_personnalise', 10, 2);
function html_stock_personnalise($html, $product) {
$stock_quantity = $product->get_stock_quantity();
if ($product->is_in_stock()) {
if ($stock_quantity > 10) {
$html = '✓ En stock (nombreuses unités)
';
} elseif ($stock_quantity > 0) {
$html = '⚠️ Stock limité (' . $stock_quantity . ' restants)
';
} else {
$html = '✓ Disponible
';
}
} else {
$html = '✗ Rupture de stock - Retour prévu sous 10 jours
';
}
return $html;
}
Chargement des actualités...