woocommerce_product_is_in_stock
Filters whether a product is in stock.
Использование
add_filter( 'woocommerce_product_is_in_stock', 'wp_kama_woocommerce_product_is_in_stock_filter', 10, 2 );
/**
* Function for `woocommerce_product_is_in_stock` filter-hook.
*
* @param bool $in_stock Whether the product is in stock.
* @param WC_Product $product Product object.
*
* @return bool
*/
function wp_kama_woocommerce_product_is_in_stock_filter( $in_stock, $product ){
// filter...
return $in_stock;
}
- $in_stock(true|false)
- Whether the product is in stock.
- $product(WC_Product)
- Product object.
Список изменений
| С версии 2.7.0 | Введена. |
Где вызывается хук
woocommerce_product_is_in_stock
woocommerce/includes/abstracts/abstract-wc-product.php 1826
return apply_filters( 'woocommerce_product_is_in_stock', ProductStockStatus::OUT_OF_STOCK !== $this->get_stock_status(), $this );