Fix to ensure stock status is updated, even when meta is blank. Prevents new products being hidden when the option to hide out of stock products is enabled.
This commit is contained in:
parent
4c52422fc3
commit
1cafd4f566
|
@ -217,9 +217,7 @@ class WC_Product {
|
||||||
public function set_stock_status( $status ) {
|
public function set_stock_status( $status ) {
|
||||||
$status = ( 'outofstock' === $status ) ? 'outofstock' : 'instock';
|
$status = ( 'outofstock' === $status ) ? 'outofstock' : 'instock';
|
||||||
|
|
||||||
if ( $this->stock_status != $status ) {
|
if ( update_post_meta( $this->id, '_stock_status', $status ) ) {
|
||||||
update_post_meta( $this->id, '_stock_status', $status );
|
|
||||||
|
|
||||||
do_action( 'woocommerce_product_set_stock_status', $this->id, $status );
|
do_action( 'woocommerce_product_set_stock_status', $this->id, $status );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue