Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Abandoned Basket in ACS

dsmims
Level 2
Level 2

Hi All,

 

Looking for a pointer in the right direction, as part of trying to get an Abandoned basket use case to work. Everything is generally all setup and working from the Website to Triggers firing and then email sending from ACS.

 

Question is, in the Trigger payload we have the cartAddition and cartRemoval collections, is it possible in Triggers/Analytics side or maybe ACS to do something/manipulate the data captured at that point in order to send an email that would only contain products that don't appear in cartRemovals?

 

Thinking along the lines of a user can add multiple products to their basket, but decide they don't want one or more of these. Currently using the cartAdditions to populate the email, a customer would then end up receiving an email containing products the have removed from their basket. 

 

Thanks,

Don

1 Reply
denisb91363072
Employee
Employee

Hi Don,

Yes it's doable a bit cumbersome but you'll be able to get the true basket in a Content Block. The code also stops the delivery is there is no product in the basket

Hope this helps

Thanks

Denis

 

<% var nbProducts = 0;%>
<% var productsToKeep = []; %>
<% var productsToExclude = []; %>
<% var nbProductsToExclude = 0; %>
<% if (context.rtEvent.ctx.analytic**bleep**Summary_products_cartAdditions.length > 0) { %>
<% for (var i =0; i < context.rtEvent.ctx.analytic**bleep**Summary_products_cartAdditions.length; i++) { %>
<% if (context.rtEvent.ctx.analytic**bleep**Summary_products_cartRemovals.length > 0) { %>
<% for (var j =0; j < context.rtEvent.ctx.analytic**bleep**Summary_products_cartRemovals.length; j++) { %>
<% if (context.rtEvent.ctx.analytic**bleep**Summary_products_cartRemovals[j].analytic**bleep**Summary_products_cartRemovals_data_0_evars_evars_eVar26 == context.rtEvent.ctx.analytic**bleep**Summary_products_cartAdditions[i].analytic**bleep**Summary_products_cartAdditions_data_0_evars_evars_eVar26) { %>
<% var forceIncludeProduct = false; %> <!-- Need to look if the product is mulitple times in the cartAdd but only once in the removals array-->
<% for (var k = 0; k < productsToExclude.length; k++) { %>
<% if (productsToExclude[k] == context.rtEvent.ctx.analytic**bleep**Summary_products_cartAdditions[i].analytic**bleep**Summary_products_cartAdditions_data_0_evars_evars_eVar26) { %>
<% forceIncludeProduct = true; %>
<% k = productsToExclude.length; %>
<% } %>
<% } %>
<% if (forceIncludeProduct == false) { %>
<% productsToExclude[nbProductsToExclude] = context.rtEvent.ctx.analytic**bleep**Summary_products_cartAdditions[i].analytic**bleep**Summary_products_cartAdditions_data_0_evars_evars_eVar26; %>
<% nbProductsToExclude++; %>
<% } else { %>
<% productsToKeep[nbProducts] = context.rtEvent.ctx.analytic**bleep**Summary_products_cartAdditions[i].analytic**bleep**Summary_products_cartAdditions_data_0_evars_evars_eVar26; %>
<% nbProducts++; %>
<% } %>
<% } else { %>
<% productsToKeep[nbProducts] = context.rtEvent.ctx.analytic**bleep**Summary_products_cartAdditions[i].analytic**bleep**Summary_products_cartAdditions_data_0_evars_evars_eVar26; %>
<% nbProducts++; %>
<% } %>
<% } %>
<% } else { %>
<% productsToKeep[nbProducts] = context.rtEvent.ctx.analytic**bleep**Summary_products_cartAdditions[i].analytic**bleep**Summary_products_cartAdditions_data_0_evars_evars_eVar26; %>
<% nbProducts++;%>
<% } %>
<% } %>
<% } %>
<% if (nbProducts > 0) { %>
<% var productsAlreadyInHTML = false; %>
<% var productToAddInHTML = false; %>
<% var productsList = []; %>
<TABLE class="mayborn_items" border="0" width="100%">
<tbody>
<TR>
<TD style="padding:4px;" align="center" width="5%"></TD>
<TD style="padding:4px;" align="left" width="65%">Name</TD>
<TD style="padding:4px;" align="center" width="15%">Quantity</TD>
<TD style="padding:4px;" align="right" width="15%">Price</TD>
</TR>
<% if (context.rtEvent.ctx.analytic**bleep**Summary_products_cartAdditions.length > 0) { %>
<% for (var i =0; i < context.rtEvent.ctx.analytic**bleep**Summary_products_cartAdditions.length; i++) { %>
<% productsAlreadyInHTML = false; %>
<% productToAddInHTML = false; %>
<% for (var j = 0; j < productsToKeep.length; j++) { %>
<% if (productsToKeep[j] == context.rtEvent.ctx.analytic**bleep**Summary_products_cartAdditions[i].analytic**bleep**Summary_products_cartAdditions_data_0_evars_evars_eVar26) { %>
<% productToAddInHTML = true; %>
<% j = productsToKeep.length; %>
<% } %> <!-- End If name in list matches a product to keep -->
<% } %> <!-- End for loop productsToKeep = true -->
<% if (productToAddInHTML == true) { %>
<% for (var k = 0; k < productsList.length; k++) { %>
<% if (productsList[k] == context.rtEvent.ctx.analytic**bleep**Summary_products_cartAdditions[i].analytic**bleep**Summary_products_cartAdditions_data_0_evars_evars_eVar26) { %>
<% productsAlreadyInHTML = true; %>
<% k = productsList.length; %>
<% } %> <!-- End If name in list matches what is already in the HTML = true -->
<% productsList[k] = context.rtEvent.ctx.analytic**bleep**Summary_products_cartAdditions[i].analytic**bleep**Summary_products_cartAdditions_data_0_evars_evars_eVar26; %>
<% } %> <!-- End for loop productsList = true -->
<% if (i == 0) {%>
<% productsList[0] = context.rtEvent.ctx.analytic**bleep**Summary_products_cartAdditions[i].analytic**bleep**Summary_products_cartAdditions_data_0_evars_evars_eVar26; %>
<% } %> <!-- End 1st line to be added (i ==0) -->
<% } else { %> <!-- End If productToAddInHTML = true -->
<% productsAlreadyInHTML = true; %>
<% } %> <!-- End Else productToAddInHTML = true -->
<% if (productsAlreadyInHTML == false) { %>
<TR>
<TD style="padding:4px;" align="center"> <img src="<%= context.rtEvent.ctx.analytic**bleep**Summary_products_cartAdditions[i].analytic**bleep**Summary_products_cartAdditions_data_0_evars_evars_eVar23 %>?width=40&height=40&quality=80&mode=crop" style="height: 40px; width: 40px" title="<%= context.rtEvent.ctx.analytic**bleep**Summary_products_cartAdditions[i].analytic**bleep**Summary_products_cartAdditions_data_0_evars_evars_eVar26 %>" alt="<%= context.rtEvent.ctx.analytic**bleep**Summary_products_cartAdditions[i].analytic**bleep**Summary_products_cartAdditions_data_0_evars_evars_eVar26 %>" width="40" height="40"> </TD>
<TD style="padding:4px;" align="left"> <%= context.rtEvent.ctx.analytic**bleep**Summary_products_cartAdditions[i].analytic**bleep**Summary_products_cartAdditions_data_0_evars_evars_eVar26 %> </TD>
<TD style="padding:4px;" align="center"> <%= context.rtEvent.ctx.analytic**bleep**Summary_products_cartAdditions[i].analytic**bleep**Summary_products_cartAdditions_data_0_evars_evars_eVar24 %> </TD>
<TD style="padding:4px;" align="right"> <%= context.rtEvent.ctx.analytic**bleep**Summary_products_cartAdditions[i].analytic**bleep**Summary_products_cartAdditions_data_0_evars_evars_eVar25 %> </TD>

</TR>
<% } %> <!-- End If productsAlreadyInHTML = false -->
<% } %> <!-- End for loop cartAdditions -->
<% } else {%>
<% } %> <!-- End Else cartAdditions.length = 0-->
</tbody>
</TABLE>
<% } else { %>
<% logError("There is no product in the basket, this email will not be sent"); %>
<% } %> <!-- End If nbProducts > 0-->