Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
//get summary ITEMS looked at
var reqSumItems = {
    event_type: "survey_data_request",
    action: "get_shop_shelf_summary_items_looked_at",
    data: {
        target: {
            survey_id: survey_id,
            respondent_id: respondent_id,
            block_id: "shelf",
        },
    },
};

var reqSumItemsStr = JSON.stringify(reqSumItems);

var resultAPIcall3 = $.parseJSON(
    $.ajax({
        url: "https://public-survey-data-api.rose.conceptsauce.io/api",
        type: "POST",
        data: reqSumItemsStr,
        dataType: "json",
        async: false,
        success: function (result) {
            console.log("success api call Summary Items");
            console.log(result);
        },
        error: function (error) {
            console.log(error);
        },
    }).responseText
);


//recode all items looked at(bought and not bought, abe vsi4ki)
var itemsLookedAt = resultAPIcall3.data.items_looked_at;

var P1look = Confirmit.page.getQuestion("P1looked");
P1look.setValue(null);

var P1lookArr = [];

for (var p = 0; p < itemsLookedAt.length; p++) {
    P1lookArr.push(itemsLookedAt[p].sku);
}

P1look.setValue(P1lookArr);

...

STEP 2.5

Get all the items the respondent have looked atCreating the object that will pass the selected favorite to be grayed out:

Code Block
languagejs
 var greyoutObj = {
                    "shelf": {
                      "set:disabled_products": [
                      ]
                    }
                  }
 
  var chosen = "^f('SKU')[f('P2').get()].label()^";
  
    greyoutObj.shelf["set:disabled_products"].push(chosen);
     
  var chosenParam = JSON.stringify(greyoutObj);
  var end = btoa(chosenParam);

var linkquestion = Confirmit.page.getQuestion("linkDisabled");
linkquestion.setValue(end);

...