0

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 2

1

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

1
  • Thanks, I missed that point. Commented Jul 22, 2020 at 8:23
1

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.

2
  • Thanks Johannes. Just a question. When I send the payload you suggested: how does Email Recommendations know that this item should be removed from cart. As I see it, it seems that just another item will added. Commented Jul 21, 2020 at 9:59
  • 1
    No you do not add an item, as per instructions and so on you will always need to add the WHOLE "current" cart to your recommendation call. This way you will increase the cart array or decrease it. Commented Jul 21, 2020 at 13:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .