woocommerce_pay_order_product_has_enough_stock
Filters whether or not the product has enough stock.
Usage
add_filter( 'woocommerce_pay_order_product_has_enough_stock', 'wp_kama_woocommerce_pay_order_product_has_enough_stock_filter', 10, 3 ); /** * Function for `woocommerce_pay_order_product_has_enough_stock` filter-hook. * * @param boolean $condition True if has enough stock. * @param \WC_Product $product Product. * @param \WC_Order $order Order. * * @return boolean */ function wp_kama_woocommerce_pay_order_product_has_enough_stock_filter( $condition, $product, $order ){ // filter... return $condition; }
- $condition(true|false)
- True if has enough stock.
- $product(\WC_Product)
- Product.
- $order(\WC_Order)
- Order.
Changelog
Since 9.8.0 | Introduced. |
Since 9.8.0 | -dev |
Where the hook is called
woocommerce_pay_order_product_has_enough_stock
woocommerce_pay_order_product_has_enough_stock
woocommerce/src/StoreApi/Utilities/OrderController.php 664
if ( ! apply_filters( 'woocommerce_pay_order_product_has_enough_stock', ( $product->get_stock_quantity() >= ( $held_stock + $required_stock ) ), $product, $order ) ) {
woocommerce/includes/shortcodes/class-wc-shortcode-checkout.php 168
if ( ! apply_filters( 'woocommerce_pay_order_product_has_enough_stock', ( $product->get_stock_quantity() >= ( $held_stock + $required_stock ) ), $product, $order ) ) {