Quick Question about Javascript wording in Launch Rules | Community
Skip to main content
Level 4
September 6, 2021
Solved

Quick Question about Javascript wording in Launch Rules

  • September 6, 2021
  • 1 reply
  • 1789 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by amgup

@swanan_ 
Change to :- 

var isMarketplace = attributes.sellerName === "ABC" || attributes.sellerName==="ClickAndCollectOnly"; 

1 reply

Level 7
September 6, 2021

@swanan_ 

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.


Swanan_Author
Level 4
September 6, 2021

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

 

Swanan_Author
Level 4
September 6, 2021

@swanan_ 
Change to :- 

var isMarketplace = attributes.sellerName === "ABC" || attributes.sellerName==="ClickAndCollectOnly"; 


@amgup 

I'll try it and let you know the result.

 

Thanks a lot for your help here