I am trying to use the wix stores backend → createProduct() API, but when I call this API with the arg. of type ProductInfo, it does not fill some of the fields in the Product DB Table. I send trackInventory as true, and with it I send the quantityInStock value. But after the API is called and the entry is created in the Product table, it does not have quantity field filled and also trackInventory is set to false in the return value Promise. Similarly, I am sending the additionalInfoSections also, but this field also remains empty after API executes. I have verified the syntax for ProductInfo argument to be supplied to this API from this documentation: https://www.wix.com/corvid/reference/wix-stores-backend.html#createProduct .
Please help me regarding this issue.
Hi,
As it might be the issue with the API itself. I’d recommend contacting Wix Customer Care here .
Include the site and the page where you have implemented the solution, clear description of the issue, and screenshot or a screencast if possible.
The input argument to the createProduct() function is an object of type ProductInfo. The ProductInfo object does not have fields like, quantityInStock, additionalInfoSection etc.
For updating quantityInStock follow these steps:
Set manageVariants to True in createProduct () argument.
Set some productOptions values as per syntax in the createProduct () argument.
With this ProductInfo object created call the createProduct() API.
Now, use the updateInventoryVariantFieldsByExternalId() backend function and update the inventory options for tracking the quantity.
@anders yes, we need to unecessarily create variants, if we are using the API to create a product. I had asked customer care about it, but they did not provide proper Support.