diff --git a/packages/js/api/CHANGELOG.md b/packages/js/api/CHANGELOG.md index ea1d2914f4b..5dfbc182b10 100644 --- a/packages/js/api/CHANGELOG.md +++ b/packages/js/api/CHANGELOG.md @@ -1,5 +1,9 @@ # Unreleased +## Added + +- Added low stock threshold field for products + # 0.2.0 ## Added diff --git a/packages/js/api/src/models/products/abstract/inventory.ts b/packages/js/api/src/models/products/abstract/inventory.ts index 9a477bda9dd..7fb6dac7a57 100644 --- a/packages/js/api/src/models/products/abstract/inventory.ts +++ b/packages/js/api/src/models/products/abstract/inventory.ts @@ -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 {} diff --git a/packages/js/api/src/models/products/shared/types.ts b/packages/js/api/src/models/products/shared/types.ts index d127181b445..c72b92cffa8 100644 --- a/packages/js/api/src/models/products/shared/types.ts +++ b/packages/js/api/src/models/products/shared/types.ts @@ -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. diff --git a/packages/js/api/src/models/products/simple-product.ts b/packages/js/api/src/models/products/simple-product.ts index dd12635b8cf..b774ae84c57 100644 --- a/packages/js/api/src/models/products/simple-product.ts +++ b/packages/js/api/src/models/products/simple-product.ts @@ -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 diff --git a/packages/js/api/src/models/products/variable-product.ts b/packages/js/api/src/models/products/variable-product.ts index 6433502d8ac..55346f53b33 100644 --- a/packages/js/api/src/models/products/variable-product.ts +++ b/packages/js/api/src/models/products/variable-product.ts @@ -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 diff --git a/packages/js/api/src/models/products/variation.ts b/packages/js/api/src/models/products/variation.ts index beb1bad8071..61279b0e524 100644 --- a/packages/js/api/src/models/products/variation.ts +++ b/packages/js/api/src/models/products/variation.ts @@ -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 diff --git a/packages/js/api/src/repositories/rest/products/shared.ts b/packages/js/api/src/repositories/rest/products/shared.ts index 8105a270734..9cd81bde891 100644 --- a/packages/js/api/src/repositories/rest/products/shared.ts +++ b/packages/js/api/src/repositories/rest/products/shared.ts @@ -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', }, ), ];