Filters whether a product is in stock.
Filtre si un produit est en stock.
ProductStockStatus::OUT_OF_STOCK !== $this->get_stock_status(
Sortie :
@param bool $in_stock Whether the product is in stock. @param WC_Product $product Product object.
// Modifier le statut de stock dynamiquement
add_filter('woocommerce_product_is_in_stock', 'verifier_stock_personnalise', 10, 2);
function verifier_stock_personnalise($is_in_stock, $product) {
// Vérifier dans un système externe
// Bloquer si stock externe insuffisant
$stock_externe = get_post_meta($product->get_id(), '_stock_externe', true);
if ($stock_externe && $stock_externe < 1) {
return false;
}
return $is_in_stock;
}
Chargement des actualités...