Merge pull request #31484 from woocommerce/add/low-stock-threshold
Add low stock threshold to the WooCommerce API package
This commit is contained in:
commit
0023c319d2
|
@ -1,5 +1,9 @@
|
|||
# Unreleased
|
||||
|
||||
## Added
|
||||
|
||||
- Added low stock threshold field for products
|
||||
|
||||
# 0.2.0
|
||||
|
||||
## Added
|
||||
|
|
|
@ -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 {}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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',
|
||||
},
|
||||
),
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue