woocommerce_pay_order_product_has_enough_stock

woocommerce_pay_order_product_has_enough_stock

Appears in: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Hook Type: filter

See hook in core

Displaying hooks found in version: woocommerce.9.3.3

apply_filters('woocommerce_pay_order_product_has_enough_stock') is found 2 times:

  • /includes/shortcodes/class-wc-shortcode-checkout.php line 167
    								// Check stock based on all items in the cart and consider any held stock within pending orders.
    								$held_stock     = wc_get_held_stock_quantity( $product, $order->get_id() );
    								$required_stock = $quantities[ $product->get_stock_managed_by_id() ];
    
    								if ( ! apply_filters( 'woocommerce_pay_order_product_has_enough_stock', ( $product->get_stock_quantity() >= ( $held_stock + $required_stock ) ), $product, $order ) ) {
    									/* translators: 1: product name 2: quantity in stock */
    									throw new Exception( sprintf( __( 'Sorry, we do not have enough "%1$s" in stock to fulfill your order (%2$s available). We apologize for any inconvenience caused.', 'woocommerce' ), $product->get_name(), wc_format_stock_quantity_for_display( $product->get_stock_quantity() - $held_stock, $product ) ) );
    								}
    							}
    						}
    					}
    
  • /src/StoreApi/Utilities/OrderController.php line 649
    						 * @param \WC_Order $order Order.
    						 *
    						 * @since 9.8.0-dev
    						 */
    						if ( ! apply_filters( 'woocommerce_pay_order_product_has_enough_stock', ( $product->get_stock_quantity() >= ( $held_stock + $required_stock ) ), $product, $order ) ) {
    							/* translators: 1: product name 2: quantity in stock */
    							return array(
    								'code'    => 'woocommerce_rest_out_of_stock',
    								/* translators: %s: product name */
    								'message' => sprintf( __( 'Sorry, we do not have enough "%1$s" in stock to fulfill your order (%2$s available). We apologize for any inconvenience caused.', 'woocommerce' ), $product->get_name(), wc_format_stock_quantity_for_display( $product->get_stock_quantity() - $held_stock, $product ) ),
    							);