* Revert "Set value to stock quantity" This reverts commit4350f497fd
. * Revert "Undo set_stock_quantity" This reverts commit19affd841b
. * Add changelog * Fix lint * Fix lint * Fix lint warning * Undo set_stock_quantity
This commit is contained in:
parent
c7fcc8eaac
commit
5811655e1a
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
|
||||
Revert "Set stock quantity value as 0 by default (#48448)" #48863
|
|
@ -74,7 +74,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|
|||
'tax_status' => 'taxable',
|
||||
'tax_class' => '',
|
||||
'manage_stock' => false,
|
||||
'stock_quantity' => 0,
|
||||
'stock_quantity' => null,
|
||||
'stock_status' => 'instock',
|
||||
'backorders' => 'no',
|
||||
'low_stock_amount' => '',
|
||||
|
@ -358,10 +358,10 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|
|||
* Returns number of items available for sale.
|
||||
*
|
||||
* @param string $context What the value is for. Valid values are view and edit.
|
||||
* @return int
|
||||
* @return int|null
|
||||
*/
|
||||
public function get_stock_quantity( $context = 'view' ) {
|
||||
return $this->get_prop( 'stock_quantity', $context ) ?? 0;
|
||||
return $this->get_prop( 'stock_quantity', $context );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -966,7 +966,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|
|||
* @param float|null $quantity Stock quantity.
|
||||
*/
|
||||
public function set_stock_quantity( $quantity ) {
|
||||
$this->set_prop( 'stock_quantity', '' !== $quantity ? wc_stock_amount( $quantity ) : 0 );
|
||||
$this->set_prop( 'stock_quantity', '' !== $quantity ? wc_stock_amount( $quantity ) : null );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -332,7 +332,7 @@ class WC_Meta_Box_Product_Data {
|
|||
$classname = WC_Product_Factory::get_product_classname( $post_id, $product_type ? $product_type : 'simple' );
|
||||
$product = new $classname( $post_id );
|
||||
$attributes = self::prepare_attributes();
|
||||
$stock = 0;
|
||||
$stock = null;
|
||||
|
||||
// Handle stock changes.
|
||||
if ( isset( $_POST['_stock'] ) ) {
|
||||
|
@ -483,7 +483,7 @@ class WC_Meta_Box_Product_Data {
|
|||
}
|
||||
$variation_id = absint( $_POST['variable_post_id'][ $i ] );
|
||||
$variation = wc_get_product_object( 'variation', $variation_id );
|
||||
$stock = 0;
|
||||
$stock = null;
|
||||
|
||||
// Handle stock changes.
|
||||
if ( isset( $_POST['variable_stock'], $_POST['variable_stock'][ $i ] ) ) {
|
||||
|
|
|
@ -56,7 +56,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
woocommerce_wp_text_input(
|
||||
array(
|
||||
'id' => '_stock',
|
||||
'value' => wc_stock_amount( $product_object->get_stock_quantity( 'edit' ) ),
|
||||
'value' => wc_stock_amount( $product_object->get_stock_quantity( 'edit' ) ?? 1 ),
|
||||
'label' => __( 'Quantity', 'woocommerce' ),
|
||||
'desc_tip' => true,
|
||||
'description' => __( 'Stock quantity. If this is a variable product this value will be used to control stock for all variations, unless you define stock at variation level.', 'woocommerce' ),
|
||||
|
|
|
@ -1640,7 +1640,7 @@ CREATE TABLE {$wpdb->prefix}wc_product_meta_lookup (
|
|||
`min_price` decimal(19,4) NULL default NULL,
|
||||
`max_price` decimal(19,4) NULL default NULL,
|
||||
`onsale` tinyint(1) NULL default 0,
|
||||
`stock_quantity` double NULL default 0,
|
||||
`stock_quantity` double NULL default NULL,
|
||||
`stock_status` varchar(100) NULL default 'instock',
|
||||
`rating_count` bigint(20) NULL default 0,
|
||||
`average_rating` decimal(3,2) NULL default 0.00,
|
||||
|
|
|
@ -329,7 +329,7 @@ class WC_Product_Variation extends WC_Product_Simple {
|
|||
* Returns number of items available for sale.
|
||||
*
|
||||
* @param string $context What the value is for. Valid values are view and edit.
|
||||
* @return int
|
||||
* @return int|null
|
||||
*/
|
||||
public function get_stock_quantity( $context = 'view' ) {
|
||||
$value = $this->get_prop( 'stock_quantity', $context );
|
||||
|
@ -338,7 +338,7 @@ class WC_Product_Variation extends WC_Product_Simple {
|
|||
if ( 'view' === $context && 'parent' === $this->get_manage_stock() ) {
|
||||
$value = apply_filters( $this->get_hook_prefix() . 'stock_quantity', $this->parent_data['stock_quantity'], $this );
|
||||
}
|
||||
return $value ?? 0;
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1399,12 +1399,12 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
|
|||
* Uses locking to update the quantity. If the lock is not acquired, change is lost.
|
||||
*
|
||||
* @since 3.0.0 this supports set, increase and decrease.
|
||||
* @param int $product_id_with_stock Product ID.
|
||||
* @param int|float $stock_quantity Stock quantity.
|
||||
* @param string $operation Set, increase and decrease.
|
||||
* @param int $product_id_with_stock Product ID.
|
||||
* @param int|float|null $stock_quantity Stock quantity.
|
||||
* @param string $operation Set, increase and decrease.
|
||||
* @return int|float New stock level.
|
||||
*/
|
||||
public function update_product_stock( $product_id_with_stock, $stock_quantity = 0, $operation = 'set' ) {
|
||||
public function update_product_stock( $product_id_with_stock, $stock_quantity = null, $operation = 'set' ) {
|
||||
global $wpdb;
|
||||
|
||||
// Ensures a row exists to update.
|
||||
|
@ -2110,7 +2110,7 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
|
|||
if ( 'wc_product_meta_lookup' === $table ) {
|
||||
$price_meta = (array) get_post_meta( $id, '_price', false );
|
||||
$manage_stock = get_post_meta( $id, '_manage_stock', true );
|
||||
$stock = 'yes' === $manage_stock ? wc_stock_amount( get_post_meta( $id, '_stock', true ) ) : 0;
|
||||
$stock = 'yes' === $manage_stock ? wc_stock_amount( get_post_meta( $id, '_stock', true ) ) : null;
|
||||
$price = wc_format_decimal( get_post_meta( $id, '_price', true ) );
|
||||
$sale_price = wc_format_decimal( get_post_meta( $id, '_sale_price', true ) );
|
||||
return array(
|
||||
|
|
|
@ -96,11 +96,11 @@ interface WC_Product_Data_Store_Interface {
|
|||
*
|
||||
* Uses queries rather than update_post_meta so we can do this in one query (to avoid stock issues).
|
||||
*
|
||||
* @param int $product_id_with_stock Product ID.
|
||||
* @param int $stock_quantity Stock quantity to update to.
|
||||
* @param string $operation Either set, increase or decrease.
|
||||
* @param int $product_id_with_stock Product ID.
|
||||
* @param int|null $stock_quantity Stock quantity to update to.
|
||||
* @param string $operation Either set, increase or decrease.
|
||||
*/
|
||||
public function update_product_stock( $product_id_with_stock, $stock_quantity = 0, $operation = 'set' );
|
||||
public function update_product_stock( $product_id_with_stock, $stock_quantity = null, $operation = 'set' );
|
||||
|
||||
/**
|
||||
* Update a product's sale count directly.
|
||||
|
|
|
@ -21,7 +21,7 @@ defined( 'ABSPATH' ) || exit;
|
|||
* @param int|null $stock_quantity Stock quantity.
|
||||
* @param string $operation Type of operation, allows 'set', 'increase' and 'decrease'.
|
||||
* @param bool $updating If true, the product object won't be saved here as it will be updated later.
|
||||
* @return bool|int
|
||||
* @return bool|int|null
|
||||
*/
|
||||
function wc_update_product_stock( $product, $stock_quantity = null, $operation = 'set', $updating = false ) {
|
||||
if ( ! is_a( $product, 'WC_Product' ) ) {
|
||||
|
|
|
@ -282,7 +282,7 @@ test.describe.serial( 'Orders API tests', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -355,7 +355,7 @@ test.describe.serial( 'Orders API tests', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -434,7 +434,7 @@ test.describe.serial( 'Orders API tests', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -510,7 +510,7 @@ test.describe.serial( 'Orders API tests', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -575,7 +575,7 @@ test.describe.serial( 'Orders API tests', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -648,7 +648,7 @@ test.describe.serial( 'Orders API tests', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -721,7 +721,7 @@ test.describe.serial( 'Orders API tests', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -786,7 +786,7 @@ test.describe.serial( 'Orders API tests', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -863,7 +863,7 @@ test.describe.serial( 'Orders API tests', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: 'reduced-rate',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -932,7 +932,7 @@ test.describe.serial( 'Orders API tests', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -1005,7 +1005,7 @@ test.describe.serial( 'Orders API tests', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -1070,7 +1070,7 @@ test.describe.serial( 'Orders API tests', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -1147,7 +1147,7 @@ test.describe.serial( 'Orders API tests', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -1220,7 +1220,7 @@ test.describe.serial( 'Orders API tests', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -1312,7 +1312,7 @@ test.describe.serial( 'Orders API tests', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -1403,7 +1403,7 @@ test.describe.serial( 'Orders API tests', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -1488,7 +1488,7 @@ test.describe.serial( 'Orders API tests', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -1574,7 +1574,7 @@ test.describe.serial( 'Orders API tests', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
stock_status: 'instock',
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
|
@ -1620,7 +1620,7 @@ test.describe.serial( 'Orders API tests', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
stock_status: 'instock',
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
|
@ -1666,7 +1666,7 @@ test.describe.serial( 'Orders API tests', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
stock_status: 'instock',
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
|
@ -1712,7 +1712,7 @@ test.describe.serial( 'Orders API tests', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
stock_status: 'instock',
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
|
@ -1773,7 +1773,7 @@ test.describe.serial( 'Orders API tests', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -1850,7 +1850,7 @@ test.describe.serial( 'Orders API tests', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
stock_status: 'instock',
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
|
@ -1891,7 +1891,7 @@ test.describe.serial( 'Orders API tests', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
stock_status: 'instock',
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
|
@ -1932,7 +1932,7 @@ test.describe.serial( 'Orders API tests', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
stock_status: 'instock',
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
|
|
|
@ -250,7 +250,7 @@ test.describe( 'Products API tests: List All Products', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -323,7 +323,7 @@ test.describe( 'Products API tests: List All Products', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -402,7 +402,7 @@ test.describe( 'Products API tests: List All Products', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -478,7 +478,7 @@ test.describe( 'Products API tests: List All Products', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -543,7 +543,7 @@ test.describe( 'Products API tests: List All Products', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -616,7 +616,7 @@ test.describe( 'Products API tests: List All Products', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -689,7 +689,7 @@ test.describe( 'Products API tests: List All Products', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -754,7 +754,7 @@ test.describe( 'Products API tests: List All Products', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -831,7 +831,7 @@ test.describe( 'Products API tests: List All Products', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: 'reduced-rate',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -900,7 +900,7 @@ test.describe( 'Products API tests: List All Products', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -973,7 +973,7 @@ test.describe( 'Products API tests: List All Products', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -1038,7 +1038,7 @@ test.describe( 'Products API tests: List All Products', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -1115,7 +1115,7 @@ test.describe( 'Products API tests: List All Products', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -1188,7 +1188,7 @@ test.describe( 'Products API tests: List All Products', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -1280,7 +1280,7 @@ test.describe( 'Products API tests: List All Products', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -1371,7 +1371,7 @@ test.describe( 'Products API tests: List All Products', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -1456,7 +1456,7 @@ test.describe( 'Products API tests: List All Products', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -1542,7 +1542,7 @@ test.describe( 'Products API tests: List All Products', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
stock_status: 'instock',
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
|
@ -1588,7 +1588,7 @@ test.describe( 'Products API tests: List All Products', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
stock_status: 'instock',
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
|
@ -1634,7 +1634,7 @@ test.describe( 'Products API tests: List All Products', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
stock_status: 'instock',
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
|
@ -1680,7 +1680,7 @@ test.describe( 'Products API tests: List All Products', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
stock_status: 'instock',
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
|
@ -1741,7 +1741,7 @@ test.describe( 'Products API tests: List All Products', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
backordered: false,
|
||||
|
@ -1818,7 +1818,7 @@ test.describe( 'Products API tests: List All Products', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
stock_status: 'instock',
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
|
@ -1859,7 +1859,7 @@ test.describe( 'Products API tests: List All Products', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
stock_status: 'instock',
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
|
@ -1900,7 +1900,7 @@ test.describe( 'Products API tests: List All Products', () => {
|
|||
tax_status: 'taxable',
|
||||
tax_class: '',
|
||||
manage_stock: false,
|
||||
stock_quantity: 0,
|
||||
stock_quantity: null,
|
||||
stock_status: 'instock',
|
||||
backorders: 'no',
|
||||
backorders_allowed: false,
|
||||
|
|
|
@ -135,7 +135,7 @@ class WC_Tests_Product_Data extends WC_Unit_Test_Case {
|
|||
$product->set_stock_quantity( 5 );
|
||||
$product->set_stock_status( 'instock' );
|
||||
$product->save();
|
||||
$this->assertEquals( 0, $product->get_stock_quantity() );
|
||||
$this->assertEquals( '', $product->get_stock_quantity() );
|
||||
$this->assertEquals( 'instock', $product->get_stock_status() );
|
||||
$product->set_stock_status( 'outofstock' );
|
||||
$product->save();
|
||||
|
|
|
@ -917,11 +917,14 @@ class WC_Tests_Product_Functions extends WC_Unit_Test_Case {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test: test_wc_update_product_stock_should_return_old_value_if_not_managing_stock.
|
||||
* Test: test_wc_update_product_stock_should_return_null_if_not_managing_stock.
|
||||
*/
|
||||
public function test_wc_update_product_stock_should_return_old_value_if_not_managing_stock() {
|
||||
public function test_wc_update_product_stock_should_return_null_if_not_managing_stock() {
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
$this->assertEquals( 0, wc_update_product_stock( $product, 3 ) );
|
||||
$product->set_stock_quantity( 5 );
|
||||
$product->save();
|
||||
|
||||
$this->assertNull( wc_update_product_stock( $product, 3 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,7 +37,7 @@ class WC_Tests_Product_Variable extends WC_Unit_Test_Case {
|
|||
$product->set_stock_quantity( 5 );
|
||||
$product->set_stock_status( 'instock' );
|
||||
$product->save();
|
||||
$this->assertEquals( 0, $product->get_stock_quantity() );
|
||||
$this->assertEquals( '', $product->get_stock_quantity() );
|
||||
$this->assertEquals( 'outofstock', $product->get_stock_status() );
|
||||
|
||||
$product->set_manage_stock( true );
|
||||
|
|
Loading…
Reference in New Issue