Update includes/data-stores/class-wc-product-data-store-cpt.php

Co-authored-by: Néstor Soriano <konamiman@konamiman.com>
This commit is contained in:
pjv 2020-12-02 06:49:56 -06:00 committed by GitHub
parent 49c85e9c5e
commit b4fdf17215
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -572,8 +572,22 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
case 'stock_quantity':
// Fire actions to let 3rd parties know the stock is about to be changed.
if ( $product->is_type( 'variation' ) ) {
/**
* Action to signal that the value of 'stock_quantity' for a variation is about to change.
*
* @since 4.9
*
* @param int $product The variation whose stock is about to change.
*/
do_action( 'woocommerce_variation_before_set_stock', $product );
} else {
/**
* Action to signal that the value of 'stock_quantity' for a product is about to change.
*
* @since 4.9
*
* @param int $product The product whose stock is about to change.
*/
do_action( 'woocommerce_product_before_set_stock', $product );
}
break;