SimpleBasketObj

simpleBasketObj()

simpleBasketObj returns a plain JS Array containing a simplified basket dataset from the basketContents section of the survey data. Basket data will be extracted, if possible, from any level qObj thus the simpleBasketObj method can be applied to a whole respondent data set or a filtered view as needed.

Each Array element will be a plain JS Object containing the data for a single basket. As part of simplifying the available basket data the simpleBasketObj also pre-calculates some fields of interest (see below).

If the source qObj has no valid basket data then simpleBasketObj will return an empty JS Array.

Parameters

simpleBasketObj takes no parameters

Returns

An Array of Objects with the following fields:

Table 1. Result fields
Field Notes

questionID

questionTitle

totalBasketPrice

Cost of all items in the basket

TotalBasketUniqueItems

Number if distinct products in basket as determined by UPC

basket

Array, simplified basket fields (see below)

skus

Array, unique UPC codes in the basket

Table 2. Basket Array fields
Field Notes

qty

description

Often blank

unitPrice

totalPrice

unitPrice * qty

UPC

Hoisted copy of userMeta.UPC for convenience

Example of using baskets
var basket = r
  .questions()
  .simpleBasketObj()
console.log(basket)

Head to the Sandbox to experiment with simplebasketObj.