woocommerce_product_set_stock

woocommerce_product_set_stock

Appears in: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Hook Type: action
See hook in action

See hook in core

Displaying hooks found in version: woocommerce.9.5.1

do_action('woocommerce_product_set_stock') is found 2 times:

  • /includes/data-stores/class-wc-product-data-store-cpt.php line 841
    837
    838
    839
    840
    841
    842
    843
    844
    845
    846
    847
             * @since 3.0
             *
             * @param WC_Product $product The variation whose stock has changed.
             */
            do_action( 'woocommerce_product_set_stock', $product );
        }
    }
     
    if ( in_array( 'stock_status', $this->updated_props, true ) ) {
        if ( $product->is_type( 'variation' ) ) {
            /**
  • /includes/wc-stock-functions.php line 73
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
                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 );
            }
     
            return $product_with_stock->get_stock_quantity();
        }
        return $product->get_stock_quantity();
    }

See this hook used in plugins: