The Range - Stock update - In progress
The purpose of this document is to describe the requirements of updating quantity to “The Range“ marketplace.
Update Quantity flow seems straight forward- we should push the product code (which in our case will be the SKU) and also the quantity to a product. We can send updates to multiple SKUs, as in case of error, into the response we will receive the SKUs for which we have an error. The major specific for The Range is we need to make sure when creating a product, we will not put the status of a product directly to Product Published, but on Product Created. This is mandatory because into the payload for creating product we are not pushing quantity! So, following this logic, for Stock Updates we will have 2 cases - once we perform standard stock update to already published products, and the second case - once we have created a product and we would want to activate it.
*Important:** As we do not have a node for stock in “Create Product“ call, we should send stock update call immediately after we create a product on The Range website.
Stock update flow & statuses:
Case 1: Already Published product:
We can perform stock update, If we have following internal statuses:
Product status -Product Published; Listing Status - Active ; **Update Quantity - Pending**
If update was successful, we will have following statuses:
Product status -Product Published ; Listing Status -Active ; Update Quantity - Not Needed
If we receive an error, we will have:
Product status -Product Published; ; Listing Status - Active Update Quantity - Error
Case 2: Already Created product: Positive QTY is a must! (Need to be tested, it is based on assumption only)
Product status -Product Created; Listing Status - Inactive ; **Update Quantity - Pending or List/Update the Whole item = Pending?**
If update was successful, we will have following statuses:
Product status -Product Published ; Listing Status -Active ; Update Quantity - Not Needed or List/Update the Whole item = Not Needed
If we receive an error, we will have:
Product status -Product Created; ; Listing Status - Inactive Update Quantity - Error or List/Update the Whole item = Error
*Important:** If we send a zero stock to a product the product would just appear out of stock and it would be unpurchaseable, but best practice would be to use “active: 1”, i.e. to deactivate the product from the marketplace.
Note: Deactivation flow is detailed described in separate page.
API Docs: https://marketplacetherange.zendesk.com/hc/en-gb/articles/360018523338-API-Stock-Availability
API Call: POST https://supplier.rstore.com/rest/stock_availability.api?supplier_id=1
Example request:
{
"availability": [
{
"code": "123456",
"qty": 2
},
{
"code": "654321",
"qty": 1
}
]
}
On marketplace, we can push quantity to each variant of a product, using the SKU, which will be also the Channel Item ID.
Mapping:
Integration Field | Integration Notes | Integration Required | Hemi Mapping | Hemi Notes | |
---|---|---|---|---|---|
availability |
array of products, where each entry in the array contains keys for the product code and quantity. The format of these entries are: { "code": "123456", "qty": 2 } | Yes | |||
code |
product code used by you to identify a product. | Yes | Product > SKU | ||
qty |
quantity of stock on hand, including awaiting despatch. | Yes | Product Account > Quantity |
Example response:
{
"result":[
{
"label": "stock_availability",
"product_codes":"123456,654321"
}
]
}
Error cases:
As we are updating stock by SKU, we should store the errors in Update Quantity Error field, with the respectively text in it, in order to indicate to the user the type of the error.
1. Error case when we push one existing SKU and 2 SKUs which not exist:
Request example: (191319131913
exist!)
{
"availability": [
{
"code": "191319131913",
"qty": 2
},
{
"code": "1111",
"qty": 1
},
{
"code": "2222",
"qty": 2
}
]
}
Response example:
Stock Error(s) for supplier 11477: No record found for product code "1111". No record found for product code "2222"
In this case, we should store the error in Update Quantity Error field, with the respectively description above.
2. Error case, If we not do not fill quantity to existing product:
“No stock availability data provided“
3. If we not push the product code, we will receive the following error:
“The product's code is a required parameter“
4. If we not push the qty, we will receive the following error:
”Stock available is a required parameter”
5. If we push code which not exist, we will receive the following error:
“No record found for product code "123456"
Edge cases:
- If we send a negative value for stock, we will receive success, but the product into the MP platform will remain with quantity “0“; TBD if we would want to implement kind of validation for this case;
{
"availability": [
{
"code": "123456789",
"qty":-10
}
]
}
- If we send a float number, for example “1.3“, the stock for a product in MP will remain 1, if we send “2.3“, the stock will remain 2, i.e. it will be round up to near value.
TBD if we would want to implement kind of validation for this case;
{
"availability": [
{
"code": "123456789",
"qty":2.3
}
]
}
Please see example with the value, displayed on the MP, after we have send qty=2.3, for product 123456789
