Fix failing tests for canonical extensions due to 49583 (#50519)

Revert the addition of a new parameter in the woocommerce_product_set_stock hook, which was causing unit tests to fail in some extensions.
This commit is contained in:
Naman Malhotra 2024-08-10 03:38:23 +05:30 committed by GitHub
parent cc9d558a31
commit 10bc399c07
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 10 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: tweak
Comment: This makes an adjustment to another change that is targeted for the same 9.3 release.

View File

@ -753,9 +753,8 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
* @since 9.2 Added $stock parameter.
*
* @param WC_Product $product The variation whose stock has changed.
* @param int|float $stock The new stock value.
*/
do_action( 'woocommerce_variation_set_stock', $product, $product->get_stock_quantity() );
do_action( 'woocommerce_variation_set_stock', $product );
} else {
/**
* Action to signal that the value of 'stock_quantity' for a product has changed.
@ -764,9 +763,8 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
* @since 9.2 Added $stock parameter.
*
* @param WC_Product $product The variation whose stock has changed.
* @param int|float $stock The new stock value.
*/
do_action( 'woocommerce_product_set_stock', $product, $product->get_stock_quantity() );
do_action( 'woocommerce_product_set_stock', $product );
}
}

View File

@ -66,11 +66,11 @@ function wc_update_product_stock( $product, $stock_quantity = null, $operation =
if ( $product_with_stock->is_type( 'variation' ) ) {
// phpcs:disable WooCommerce.Commenting.CommentHooks.MissingSinceComment
/** This action is documented in includes/data-stores/class-wc-product-data-store-cpt.php */
do_action( 'woocommerce_variation_set_stock', $product_with_stock, $new_stock );
do_action( 'woocommerce_variation_set_stock', $product_with_stock );
} else {
// phpcs:disable WooCommerce.Commenting.CommentHooks.MissingSinceComment
/** This action is documented in includes/data-stores/class-wc-product-data-store-cpt.php */
do_action( 'woocommerce_product_set_stock', $product_with_stock, $new_stock );
do_action( 'woocommerce_product_set_stock', $product_with_stock );
}
return $product_with_stock->get_stock_quantity();
@ -280,13 +280,13 @@ function wc_trigger_stock_change_notifications( $order, $changes ) {
* since stock quantity can also be updated in other ways.
*
* @param WC_Product $product The product whose stock level has changed.
* @param int|float $stock_quantity The new quantity of stock.
*
* @return void
*/
function wc_trigger_stock_change_actions( $product, $stock_quantity ) {
function wc_trigger_stock_change_actions( $product ) {
$no_stock_amount = absint( get_option( 'woocommerce_notify_no_stock_amount', 0 ) );
$low_stock_amount = absint( wc_get_low_stock_amount( $product ) );
$stock_quantity = $product->get_stock_quantity();
if ( $stock_quantity <= $no_stock_amount ) {
/**
@ -308,8 +308,8 @@ function wc_trigger_stock_change_actions( $product, $stock_quantity ) {
do_action( 'woocommerce_low_stock', $product );
}
}
add_action( 'woocommerce_variation_set_stock', 'wc_trigger_stock_change_actions', 10, 2 );
add_action( 'woocommerce_product_set_stock', 'wc_trigger_stock_change_actions', 10, 2 );
add_action( 'woocommerce_variation_set_stock', 'wc_trigger_stock_change_actions' );
add_action( 'woocommerce_product_set_stock', 'wc_trigger_stock_change_actions' );
/**
* Increase stock levels for items within an order.