Link Search Menu Expand Document

Creating products and product variants through baskets

It is possible to use the basket_items array in the add-basket API endpoint to create a store of item metadata which can then be used to form segments used in Spaaza campaigns, populate item names on e-receipts and apps, and show performance using Spaaza’s analytics. For example, Spaaza can show statistics about how many items of category “Tops > Sweaters” are bought by a particular customer segment in physical stores in a month.

Spaaza’s object model contains the concept of products, product variants and barcodes. These three models have a hierarchical relationship. A product is an item sold in a transaction, for example “Aran Sweater,” which has various defined properties associated with it. A product can have multiple product variants, each one of which has its own properties. For example, one product variant' of the product "Aran Sweater" might have a colour of "blue" and a size of "XL," whilst another has colour "red" and size "M." Each product variant` can have one or more barcodes which is used to identify it in a transaction.

A product or product variant can be created via add-basket by extending the information passed to the basket_items array. In order to create a product the retailer_product_code must be included in the basket_items array, and to create a product_variant the item_barcode must be included.

Once created, updates to product or product variant metadata can be passed by altering the fields sent in the basket_item JSON object. Updates will only be processed once in every six hour period - more frequent update attempts will be ignored.

An example request that will create a product and product_variant

{
   "entity":{
      "entity_type":"chain",
      "entity_id":1743
   },
   "user":{
      "member_programme":"Spaaza",
      "member_number":"303484"
   },
   "basket":{
      "basket_platform_type":"in_store",
      "retailer_basket_code":"20201019_test_00000001",
      "basket_total_price":125,
      "basket_timestamp_iso8601":"",
      "basket_timezone_name":"Europe/Amsterdam",
      "shipping_charge":0,
      "payment_methods":[
         
      ],
      "basket_currency":{
         "currency_id":0,
         "currency_code":"EUR"
      },
      "basket_tax":[
         
      ],
      "basket_items":[
         {
            "item_barcode":"2913458432854",
            "retailer_product_code":"iou342oi",
            "item_name":"Men's Merino Aran Jumper",
            "item_description":"The Aran Jumper is a style of jumper that takes its name from the Aran Islands off the west coast of Ireland.",
            "item_price":125.00,
            "item_subtotal": 125.00,
            "item_colour":"White",
            "item_gender":"M",
            "item_brand":"Aran Jumpers ltd",
            "item_size":"L",
            "item_season":"Winter",
            "item_category":"Clothing > Tops > Jumpers > Aran Jumper",
            "item_image_url":"www.image.jpg"
         }
      ]
   }
}

This will result in the following response edited to only include the relevant product information.

{
   "result":{
      "code":1,
      "status":"ok"
   },
   "results":{
      "basket":{
         "id":1,
         "chain_id":1,
         "basket_platform_type":"in_store",
         "currency_id":2,
         "basket_total_price":125,
         "retailer_basket_code":"20201019_test_00000001",
         "basket_items":[
            {
               "product":{
                  "id":4,
                  "owner_code":"iou342oi",
                  "name":"Men's Merino Aran Jumper",
                  "description":"The Aran Jumper is a style of jumper that takes its name from the Aran Islands off the west coast of Ireland.",
                  "price":125,
                  "brand":"Aran Jumpers ltd",
                  "season":"Winter",
                  "category":"Clothing > Tops > Jumpers > Aran Jumper",
                  "webshop_url":null,
                  "image_url":"www.image.png",
                  "last_modified_date":"2020-10-19 08:31:18",
                  "created_date":"2020-10-19 08:31:18",
                  "product_variant":{
                     "id":2,
                     "condition":"new",
                     "colour":"White",
                     "barcode":[
                        
                     ],
                     "size":"M",
                     "price":125,
                     "cost_price":null,
                     "image_url":"www.image.png",
                     "web_url":null,
                     "last_modified_date":"2020-10-19 08:31:18",
                     "created_date":"2020-10-19 08:31:18"
                  }
               },
               "spaaza_product_variant_id":2,
               "inventory_owner_code":null,
               "item_barcode":"2913458432854",
               "item_quantity":1,
               "item_is_promotional":false,
               "item_price":125,
               "item_original_price":125,
               "item_subtotal":125,
               "is_identified":true,
               "excluded_from_spaaza":false
            }
         ],
         "basket_vouchers_applied":[
            
         ],
         "return_transactions":[
            
         ],
         "payment_methods":[
            
         ],
         "basket_tax":[
            {
               "id":1,
               "basket_id":1,
               "tax_rate":0.06,
               "tax_total":100
            }
         ],
         "supplementary_basket_codes":null,
         "regenerated_rewards":[
            
         ],
         "honour_vouchers_applied":[
            
         ],
         "employee":{
            "employee_code":null,
            "employee_name":null
         },
         "basket_timestamp_iso8601":"2020-10-19T08:31:18+00:00",
         "basket_timezone_name":"UTC",
         "purchase_progress":null
      },
      "user":{
         "member_programme":"spaaza",
         "member_number":3354863
      },
      "result_type":"add-basket"
   }
}

The minimum information that is required to create a product is retailer_product_code and the item_price and the minimum required information to create a product_variant is the item_barcode.

Extract of basket_items array with minimum required information to create a product and a product_variant.

{
   "basket_items":[
      {
         "item_barcode":"2913458432854",
         "retailer_product_code":"iou342oi",
         "item_price":125.00,
         "item_subtotal": 125.00
      }
   ]
}

Extract of a response from add-basket with product and product_variant information

{
   "product":{
      "id":4,
      "owner_code":"iou342oi",
      "name":null,
      "description":null,
      "price":125,
      "brand":null,
      "season":null,
      "category":null,
      "webshop_url":null,
      "image_url":null,
      "last_modified_date":"2020-10-19 08:31:18",
      "created_date":"2020-10-19 08:31:18",
      "product_variant":{
         "id":2,
         "condition":"new",
         "colour":null,
         "barcode":[
            
         ],
         "size":null,
         "price":125,
         "cost_price":null,
         "image_url":null,
         "web_url":null,
         "last_modified_date":"2020-10-19 08:31:18",
         "created_date":"2020-10-19 08:31:18"
      }
   }
}

The fields which can be used to store item metadata are described below.

Field Description
retailer_product_code (string, mandatory) The product or SKU identifier used by the retailer to identify the basket item.
item_barcode (string, mandatory) The barcode used by the retailer to identify the item.
item_name (string) The name of the product.
item_description (string) The description of the product.
item_brand (string) The brand making the product.
item_season (string) The particular season that is associated with the product.
item_category (string) A retailer category string for the product. This can be a single category name or can include a retailer category hierarchy with the names of category levels separated by the character “>”. For example this could be “Woollen Sweaters” or “Clothing > Tops > Sweaters > Woollen Sweaters”. The Spaaza product ingester interprets the hierarchical string and can run analytics on different category levels.
item_web_url (string) The url link to the product page on the webshop.
item_image_url (string) The url link to the products image.
item_price (float) The adjusted gross price being charged for the single-quantity item.
item_cost_price (float) The cost price of the product before any profit margin is added to make the SELL INCL sale price. This field can be used for simple margin analytics calculations on a per-item but also per-retailer or per-customer segment basis.
item_is_promotional (bool) This can be set true or false to override any existing Spaaza record of whether an item is on promotion.
item_colour (string) The colour of the product_variant eg. “red” or “green”.
item_size (string) The size of the inventory item, e.g. “M” or “32”.