Merge pull request #31484 from woocommerce/add/low-stock-threshold

Add low stock threshold to the WooCommerce API package
This commit is contained in:
Greg 2021-12-26 20:00:48 -07:00 committed by GitHub
commit 0023c319d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 20 additions and 4 deletions

View File

@ -1,5 +1,9 @@
# Unreleased
## Added
- Added low stock threshold field for products
# 0.2.0
## Added

View File

@ -34,7 +34,7 @@ abstract class AbstractProductInventory extends Model {
*
* @type {StockStatus}
*/
public readonly stockStatus: StockStatus = ''
public readonly stockStatus: StockStatus = '';
/**
* The status of backordering for a product.
@ -56,6 +56,13 @@ abstract class AbstractProductInventory extends Model {
* @type {boolean}
*/
public readonly isOnBackorder: boolean = false;
/**
* Indicates the threshold for when the low stock notification will be sent to the merchant.
*
* @type {number}
*/
public readonly lowStockThreshold: number = -1;
}
export interface IProductInventory extends AbstractProductInventory {}

View File

@ -53,7 +53,7 @@ export type ProductGroupedUpdateParams = 'groupedProducts';
* Properties related to tracking inventory.
*/
export type ProductInventoryUpdateParams = 'backorderStatus' | 'canBackorder' | 'trackInventory'
| 'onePerOrder' | 'remainingStock';
| 'onePerOrder' | 'remainingStock' | 'lowStockThreshold';
/**
* Properties related to sales tax.

View File

@ -130,10 +130,11 @@ export class SimpleProduct extends AbstractProduct implements
public readonly onePerOrder: boolean = false;
public readonly trackInventory: boolean = false;
public readonly remainingStock: number = -1;
public readonly stockStatus: StockStatus = ''
public readonly stockStatus: StockStatus = '';
public readonly backorderStatus: BackorderStatus = BackorderStatus.Allowed;
public readonly canBackorder: boolean = false;
public readonly isOnBackorder: boolean = false;
public readonly lowStockThreshold: number = -1;
/**
* @see ./abstracts/price.ts

View File

@ -115,10 +115,11 @@ export class VariableProduct extends AbstractProduct implements
public readonly onePerOrder: boolean = false;
public readonly trackInventory: boolean = false;
public readonly remainingStock: number = -1;
public readonly stockStatus: StockStatus = ''
public readonly stockStatus: StockStatus = '';
public readonly backorderStatus: BackorderStatus = BackorderStatus.Allowed;
public readonly canBackorder: boolean = false;
public readonly isOnBackorder: boolean = false;
public readonly lowStockThreshold: number = -1;
/**
* @see ./abstracts/sales-tax.ts

View File

@ -118,6 +118,7 @@ export class ProductVariation extends AbstractProductData implements
public readonly backorderStatus: BackorderStatus = BackorderStatus.Allowed;
public readonly canBackorder: boolean = false;
public readonly isOnBackorder: boolean = false;
public readonly lowStockThreshold: number = -1;
/**
* @see ./abstracts/price.ts

View File

@ -345,6 +345,7 @@ export function createProductInventoryTransformation(): ModelTransformation[] {
onePerOrder: PropertyType.Boolean,
stockStatus: PropertyType.String,
backOrderStatus: PropertyType.String,
lowStockThreshold: PropertyType.Integer,
},
),
new KeyChangeTransformation< IProductInventory >(
@ -356,6 +357,7 @@ export function createProductInventoryTransformation(): ModelTransformation[] {
backorderStatus: 'backorders',
canBackorder: 'backorders_allowed',
isOnBackorder: 'backordered',
lowStockThreshold: 'low_stock_amount',
},
),
];