Sample Use Cases and Flows

This article shares a possible use case your app could support, as well as sample flows that could support this use case. This can be a helpful jumping-off point as you plan your app's implementation.

Add and arrange products in category

Help merchants to manage their products by using categories. For this we will be using the Categories API.

  1. Call Create Category and pass "@wix/stores" to the treeReference.appNamespace field.
  2. Save category.id from the response.
  3. Call Bulk Add Items To Category and pass the items you want to add to the category. After products added to category you can rearrange them for example to promote some products to be displayed in the beginning. Note that you can arrange only 100 products, more products can be added but you cannot control arrangement of them. Call Set Arranged Items endpoint. Pass exactly same params as in step 2 but now items must be in same order in which you want to see them.
  4. Now you can load all products that belongs to given category and keep their arrangement by calling Search Products endpoint of ProductService with next body
Copy

Replace <categoryId> with real category id from step 1. Pay attention to sort.selectItemsBy parameter where you must pass filter by categoryId, this allows you to sort products by arrangement that you set in CategoriesService on step 3.

Prepare store for Christmas Sale

Before big sale merchant might want to prepare store by creating a new category for products on sale, adding ribbons to products to catch visitors' attention and of course setting new sale price. Let's see how to do it step by step.

  1. Add and arrange products in category. This will allow visitor to filter by this category on storefront category page (if merchant enabled this filter in editor). Also it allows merchant to control which products visitor will see first.
  2. Create new ribbon by calling Create Ribbon endpoint of external RibbonService. Save ribbon.id that you received in response.
  3. To add ribbon "Sale!" to all products in category call Bulk Update Products By Filter endpoint. In filter send filter by category id. In product send only ribbon. So your request will look like:
Copy
  1. Finally we need to update sale prices. For simplicity let's consider single product with one variant which has basePrice 100$ and salePrice 90$.

a) If you want to adjust all sale prices by some specific amount or percentage which depends on original sale price value call Bulk Adjust Product Variants By Filter. For example if you want to decrease current sale prices by 10% pass next body:

Copy

After this call example product will have basePrice 100$ and salePrice 81$.

b) If you want to calculate new sale prices from base price by applying some discount to it call Bulk Adjust Product Variants By Filter with salePriceFromSasePrice. For example if you want to set sale as 20% discount from base price pass next body:

Copy

After this call example product will have basePrice 100$ and salePrice 80$.

c) If you want to set exact sale price same for all variants of all products call Bulk Update Product Variants By Filter endpoint with variant with desired sale price:

Copy

After this call example product will have basePrice 100$ and salePrice 75$.

Did this help?