Introduction
Â
The Stores Products API allows you to manage products to sell.
With the Products API, you can:
See Managing Products for more information.
Terminology
- Options: Property types that customers can select within the specific product. For example, color and size.
- Choices: Available selections within each option. For example, red, green, and blue as choices under the color option.
- Variants: Combinations of different product options and choices. For example, a red shirt in size large.
Setup
To use the Products API, install the @wix/stores
package using npm or Yarn:
1npm install @wix/stores
or
1yarn add @wix/stores
Then import { products }
from @wix/stores
:
1import { products } from '@wix/stores'
Adds media items to a specified product, either via URL or existing media ID.
NOTE: The URL is not validated and no event is triggered to indicate if the media was added successfully.
Permission Scopes
For app development, you must have one of the following permission scopes:function addProductMedia(_id: string, media: Array<MediaDataForWrite>): Promise<void>
Product ID.
Sources of media items already uploaded to the Wix site.
Links media items that are already associated with a specific product to a choice within the same product.
Media items can only be set for choices within one option at a time - e.g., if you set media items for some or all of the choices within the Colors option (blue, green, and red), you won't be able to also assign media items to choices within the Size option (S, M, and L).
To remove all existing media items, call the Remove Product Media From Choices endpoint.
Permission Scopes
For app development, you must have one of the following permission scopes:function addProductMediaToChoices(_id: string, media: Array<MediaAssignmentToChoice>): Promise<void>
Product ID.
Product media items and the choices to add the media to.
Adds products to a specified collection.
Permission Scopes
For app development, you must have one of the following permission scopes:function addProductsToCollection(_id: string, productIds: Array<string>): Promise<void>
Collection ID.
IDs of the products to add to the collection, separated by commas.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Adjusts a specified numerical property for up to 100 products at a time. The property can be increased or decreased either by percentage or amount.
Permission Scopes
For app development, you must have one of the following permission scopes:function bulkAdjustProductProperty(adjust: AdjustValue, ids: Array<string>): Promise<BulkAdjustProductPropertiesResponse>
Numerical property to adjust.
Product IDs.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Updates a specified property for up to 100 products at a time.
Permission Scopes
For app development, you must have one of the following permission scopes:function bulkUpdateProductsProperty(ids: Array<string>, set: SetValue): Promise<BulkUpdateProductsResponse>
Product IDs.
Field to update.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Creates a new collection.
Permission Scopes
For app development, you must have one of the following permission scopes:function createCollection(collection: Collection): Promise<CreateCollectionResponse>
Collection info.
Creates a new product.
Permission Scopes
For app development, you must have one of the following permission scopes:function createProduct(product: Product): Promise<CreateProductResponse>
Product information.
Deletes a collection.
Permission Scopes
For app development, you must have one of the following permission scopes:function deleteCollection(_id: string): Promise<void>
ID of the collection to delete.
Deletes a product.
Permission Scopes
For app development, you must have one of the following permission scopes:function deleteProduct(_id: string): Promise<void>
ID of the product to delete.
Delete all options from a specific product. Only available when variant management is disabled.
Permission Scopes
For app development, you must have one of the following permission scopes:function deleteProductOptions(_id: string): Promise<void>
ID of the product with options to delete.
Retrieves a collection with the provided slug.
Permission Scopes
For app development, you must have one of the following permission scopes:function getCollectionBySlug(slug: string): Promise<GetCollectionBySlugResponse>
Slug of the collection to retrieve.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Retrieves a product with the provided ID.
Permission Scopes
For app development, you must have one of the following permission scopes:function getProduct(_id: string, options: GetProductOptions): Promise<GetProductResponse>
Requested product ID.
Gets the availability of relevant product variants based on the product ID and selections provided. See Use Cases for an example.
Permission Scopes
For app development, you must have one of the following permission scopes:function getProductOptionsAvailability(_id: string, options: Record<string, string>): Promise<ProductOptionsAvailabilityResponse>
Requested product ID.
Array containing the selected options. For example, ["color": "Blue", "size": "Large"].
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Retrieves a store variant with the provided ID.
Permission Scopes
For app development, you must have one of the following permission scopes:function getStoreVariant(_id: string): Promise<GetStoreVariantResponse>
Store variant ID. Comprised of the productId and the variantId, separated by a hyphen. For example, {productId}-{variantId}.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Retrieves product variants, based on either choices (option-choice key-value pairs) or variant IDs. See Stores Pagination for more information.
Permission Scopes
For app development, you must have one of the following permission scopes:function queryProductVariants(_id: string, options: QueryProductVariantsOptions): Promise<QueryProductVariantsResponse>
Requested product ID.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Returns a list of up to 100 products, given the provided paging, sorting and filtering.
PROPERTY | SUPPORTED FILTERS & SORTING |
---|---|
_id | eq() ,ne() ,exists() ,in() ,hasSome() ,startsWith() ,ascending() ,descending() |
name | eq() ,ne() ,exists() ,in() ,hasSome() ,startsWith() ,ascending() ,descending() |
slug | eq() ,ne() ,exists() ,in() ,hasSome() ,startsWith() ,ascending() ,descending() |
productType | eq() ,ne() ,exists() ,in() ,hasSome() ,ascending() ,descending() |
description | eq() ,ne() ,exists() ,in() ,hasSome() ,startsWith() |
sku | eq() ,ne() ,exists() ,in() ,hasSome() ,startsWith() ,ascending() ,descending() |
price | eq() ,ne() ,exists() ,in() ,hasSome() ,ascending() ,descending() |
priceData.price | eq() ,ne() ,exists() ,in() ,hasSome() ,lt() ,le() ,gt() ,ge() ,ascending() ,descending() |
numericId | eq() ,ne() ,exists() ,in() ,hasSome() ,lt() ,le() ,gt() ,ge() ,ascending() ,descending() |
collectionIds | eq() ,ne() ,exists() ,in() ,hasSome() ,hasAll() |
lastUpdated | eq() ,ne() ,exists() ,in() ,hasSome() ,lt() ,le() ,gt() ,ge() ,ascending() ,descending() |
_createdDate | eq() ,ne() ,exists() ,in() ,hasSome() ,lt() ,le() ,gt() ,ge() |
Permission Scopes
For app development, you must have one of the following permission scopes:function queryProducts(): ProductsQueryBuilder
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Retrieves up to 100 store variants, given the provided paging, filtering, and sorting.
Permission Scopes
For app development, you must have one of the following permission scopes:function queryStoreVariants(query: PlatformQuery): Promise<QueryStoreVariantsResponse>
Query options.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Deletes a product's brand.
Permission Scopes
For app development, you must have one of the following permission scopes:function removeBrand(_id: string): Promise<void>
Product ID.
Removes specified media items from a product. Pass an empty array to remove all media items.
Permission Scopes
For app development, you must have one of the following permission scopes:function removeProductMedia(_id: string, mediaIds: Array<string>): Promise<void>
Product ID.
List of media IDs to remove. Pass an empty array to delete all media items for the product.
Removes media items from all or some of a product's choices. (Media items can only be set for choices within one option at a time - e.g., if you set media items for some or all of the choices within the Colors option (blue, green, and red), you won't be able to also assign media items to choices within the Size option (S, M, and L).)
Permission Scopes
For app development, you must have one of the following permission scopes:function removeProductMediaFromChoices(_id: string, media: Array<MediaAssignmentToChoice>): Promise<void>
Product ID from whose choices to remove media items.
Media to remove from choices. If an empty array is passed, all media will be removed from all choices for the given product.
Deletes products from a specified collection.
Permission Scopes
For app development, you must have one of the following permission scopes:function removeProductsFromCollection(_id: string, productIds: Array<string>): Promise<void>
ID of the collection from which to remove products.
IDs of the products to remove from the collection.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Deletes a product's ribbon.
Permission Scopes
For app development, you must have one of the following permission scopes:function removeRibbon(_id: string): Promise<void>
Product ID.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Resets the data (such as the price and the weight) of all variants for a given product to their default values.
Permission Scopes
For app development, you must have one of the following permission scopes:function resetAllProductVariantData(_id: string): Promise<void>
Product ID.
Updates specified properties of a collection. To add products to a collection, call the addProductsToCollection function.
Permission Scopes
For app development, you must have one of the following permission scopes:function updateCollection(_id: string, collection: UpdateCollection): Promise<UpdateCollectionResponse>
Collection ID (generated automatically by the catalog).
Collection info to update.
Updates specified fields in a product.
Permission Scopes
For app development, you must have one of the following permission scopes:function updateProduct(_id: string, product: UpdateProduct): Promise<UpdateProductResponse>
Product ID (generated automatically by the catalog).
Product info to update.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Updates variants of a specified product.
Permission Scopes
For app development, you must have one of the following permission scopes:function updateProductVariants(_id: string, variants: Array<VariantOverride>): Promise<UpdateVariantsResponse>
ID of the product with managed variants.
Variant info to update.