TransWikia.com

SFMC Email recommendations: Remove individual items from cart

Salesforce Asked by Willem Ruys on October 3, 2021

Would it be possible to create a script that removes individual items from the cart, with the current setup of Email Recommendations?

For the implementation of Email Recommendations, we are looking for a way to remove individual items from the cart. I am aware that there is a script provided by SFMC documentation to clear all items from the cart:

<script type="text/javascript">       
   _etmc.push(["setOrgId", "MID"]);       
   _etmc.push(["trackCart", { "clear_cart": true } ]);   
</script>

Unfortunately this does not fulfil the requirements.

2 Answers

As detailed in the help doc for the track cart call

This code overwrites items in the contact’s cart with the newest information, including the quantity and unit price for each item. If a cart has multiple products, each product must be added to the call each time it is captured. The active cart must be added to the call every time.

So each cart call does not add or remove from the cart it simply overwrites the current cart. So each cart call should be the current & complete cart

Correct answer by EazyE on October 3, 2021

There is no Call to "remove Cart item" if that is what you asking for.

When you want to delete an item of the cart, you need to know the current status of the cart and remove the particular item you want to remove and then send that data with the usual trackcart call. And you really need to implement the uniquevalue for the customer called "email".

Here an Example Payload that gets transferred when you perform the call:

payload: {"cart":[{"item":"ProductNumber","quantity":"1"},{"item":"ProductNumber","quantity":"1"}],"url":"https://www.XXX.eu/","user_info":{"email":"UniqueCustomerValue"}}

Result after you remove one Item:

payload: {"cart":[{"item":"ProductNumber","quantity":"1"}],"url":"https://www.XXX.eu/","user_info":{"email":"UniqueCustomerValue"}}

Currently your questions tries to communicate a solution but you should rather show your use case and not a solution you may got for this usecase. This is a common problem called XY problem.

Maybe your question leads to: How can i make sure that an item won't show up in recommendations? If you want to make a product unavailable just set the OnlineAvailability flag to No. Setting this will automatically remove the product out of every recommendation.

Answered by Johannes Schapdick on October 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP