Check current state of cart | Community
Skip to main content
Level 2
November 18, 2024
Solved

Check current state of cart

  • November 18, 2024
  • 2 replies
  • 1033 views

Hi,

 

I am working on the usual abandon cart use case. How can I check if their is any item in the cart. For example user can start the checkout and go back to remove the item from the cart, and possibly remove all items and make the cart empty.

 

How can I validate in the journey that there is atleast one item in the cart left before sending the abandon cart push?

 

TIA

Best answer by Mohan_Dugganab

You can use collection management functions https://experienceleague.adobe.com/en/docs/journey-optimizer/using/orchestrate-journeys/building-advanced-conditions-journeys/syntax/collection-management-functions to perform this check to see if there is at least one check out event and no product removals from the cart in the last x hours.

2 replies

SatheeskannaK
Community Advisor
Community Advisor
November 18, 2024
Thanks, Sathees
Level 2
November 19, 2024

Hi @satheeskannak , thank you for your response. Could you please guide me which event should I look for? I looked at the documentation you shared but couldn't find what I was looking for.

 

Currently I have following events configured in AEP, Backofficeorderplaced, productlistadds, productlistviews,purchase,checkout.

 

The problem is if I take cart value in any of these events, the cart value will be of when that event has happened, but even there is a product removal from cart, I will not know what is the current value of that cart.

I know that there is a productlistremoval event, but I am not sure if I can use that for multiple item removals.

Mohan_Dugganab
Adobe Employee
Mohan_DugganabAdobe EmployeeAccepted solution
Adobe Employee
November 19, 2024

You can use collection management functions https://experienceleague.adobe.com/en/docs/journey-optimizer/using/orchestrate-journeys/building-advanced-conditions-journeys/syntax/collection-management-functions to perform this check to see if there is at least one check out event and no product removals from the cart in the last x hours.

Level 2
November 19, 2024

Hi,

If I use this function, it will check if there nis product list removal event in last x hours. But even if there are product removals, there could still be items present in the cart. How can I tackle that?

Mohan_Dugganab
Adobe Employee
Adobe Employee
November 19, 2024

I am assuming you are relying on productListItems object array to know the number of items in the cart. If the productListItems count of checkout event is equal to count of productListItems count of the product removals since the checkout was started in the last x hours, that should give an indication there are no items in the cart.

 

Otherwise, you will need to build a custom API to check the state of the cart for a given user and use it as part of custom actions before proceeding further with further orchestration.