Hey Community,
I would like to update one of my rules in Adobe Launch which is set with Custom Code.
The goal of the rule is to set my eVar8 value (Product Type) according to the value I'm getting in my eVar7.
Example :
if eVar7 = "ABC"
Then eVar8 = "ABC.com"
Else eVar8 = "Marketplace".
s.products = flatMap(orders, function(order){
var shippingMethod = order.total.shippingMethod;
var storeName = order.total.shippingMethodID === "9" ? order.profile.shippingAddress.name : "Autre livraison";
return order.item.map(function(item){
var availabilityID = item.attributes.availabilityID || "0";
var attributes = item.attributes;
var isMarketplace = attributes.sellerName === "ABC";
var isDigital = attributes.nature === "digital";
var prid = _satellite.getVar("Adobe Analytics - Helper - Product Identifier", item);
var quantity = item.quantity || 1;
return [
// Category
"",
// Product name
prid,
// Quantity
quantity,
// Price
item.price.priceWithTax * quantity,//total
// Events
"",
// eVars
keyValues({
evar7: attributes.sellerName,
//evar8: isMarketplace ? "ABC.com" : "Marketplace",
evar8: (isDigital && isMarketplace) ? "Dematerialise" : (isMarketplace ? "ABC.com" : "Marketplace"),
evar9: Number(attributes.condition === "new"),
evar23: storeName,
evar24: shippingMethod,
}),
].join(";");
});
}).join();
As you can see above, the var isMarketplace is set with the following method :
var isMarketplace = attributes.sellerName === "ABC";
All the code above has been implemented by another developer.
I would like to get your help to understand a bit more what means the var declaration isMarketplace ? I don't get how the value is set as we have the following code in the declaration.
attributes.sellerName === "ABC";
My final goal is to update my code as the following :
if eVar7 = "ABC" || "ClickAndCollectOnly",
Then eVar8 = "ABC.com"
Else eVar8 = "Marketplace".
I'm not sure if I need to modify the declaration of var isMarketplace line or if I need to modify the ternary operator present in the keyValues Object for eVar8.
Thanks a lot for your help
Solved! Go to Solution.
Views
Replies
Total Likes
@Swanan_
Change to :-
var isMarketplace = attributes.sellerName === "ABC" || attributes.sellerName==="ClickAndCollectOnly";
Views
Replies
Total Likes
var isMarketplace = attributes.sellerName === "ABC";
Here, this variable isMarketplace will contain the boolean value. If attributes.sellerName is exactly "ABC" than true and the same will be assigned to the var isMarketplace. You may want to modify the implementation accordingly.
Hi @amgup,
Thanks a lot for your feedback.
So if I understand correctly your answer, I can modify the declaration from this:
var isMarketplace = attributes.sellerName === "ABC";
To this
var isMarketplace = attributes.sellerName === "ABC" || "ClickAndCollectOnly";
And so now it should return true if the value is ABC or ClickAndCollectOnly, right ?
Thanks again for your help
Views
Replies
Total Likes
@Swanan_
Change to :-
var isMarketplace = attributes.sellerName === "ABC" || attributes.sellerName==="ClickAndCollectOnly";
Views
Replies
Total Likes
Views
Replies
Total Likes
@Swanan_ Did the solution helped you ? If yes than can you please make the answer as correct ? If not than please let us know what error you are facing ?
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes