Merge pull request #3564 from ragulka/stock-action-hooks
Add stock set, increase and reduce action hooks
This commit is contained in:
commit
e9a168c2ee
|
@ -162,6 +162,8 @@ class WC_Product {
|
|||
$this->stock = intval( $amount );
|
||||
update_post_meta( $this->id, '_stock', $this->stock );
|
||||
|
||||
do_action( 'woocommerce_product_set_stock', $this );
|
||||
|
||||
// Out of stock attribute
|
||||
if ( ! $this->backorders_allowed() && $this->get_total_stock() <= 0 )
|
||||
$this->set_stock_status( 'outofstock' );
|
||||
|
@ -188,6 +190,8 @@ class WC_Product {
|
|||
$this->stock = $this->stock - $by;
|
||||
update_post_meta( $this->id, '_stock', $this->stock );
|
||||
|
||||
do_action( 'woocommerce_product_reduce_stock', $this, $by );
|
||||
|
||||
// Out of stock attribute
|
||||
if ( ! $this->backorders_allowed() && $this->get_total_stock() <= 0 )
|
||||
$this->set_stock_status( 'outofstock' );
|
||||
|
@ -212,6 +216,8 @@ class WC_Product {
|
|||
$this->stock = $this->stock + $by;
|
||||
update_post_meta( $this->id, '_stock', $this->stock );
|
||||
|
||||
do_action( 'woocommerce_product_increase_stock', $this, $by );
|
||||
|
||||
// Out of stock attribute
|
||||
if ( $this->backorders_allowed() || $this->get_total_stock() > 0 )
|
||||
$this->set_stock_status( 'instock' );
|
||||
|
|
Loading…
Reference in New Issue