How do I check if a user has a cart in Mendix?

0
I'm working on developing an application in Mendix where users can add products to their shopping cart. I would like to   checks if a user already has a shopping cart. If the user doesn't have a shopping cart, I want to create one for them. Does anyone have any advice on the best approach for this?  how can I implement this in a microflow? Any tips and suggestions would be greatly appreciated. Thank you! Best regards,
asked
3 answers
0

I assume you have an association User-Cart

 

You can retrieve, via association, the cart(s) the user has, if none are found, create one for them, otherwise use the one found.

answered
0

Hi Muhammad Furqan,

 

I think you are having an entity named Cart. and having an association with User entity.

 

Then, use the microflow activity retrieve and using association retrieve the cart.

 

Check with the condition, Cart! = empty by using decision. if true continue, the flow.

 

if false, then create a new object of Cart with association of current user.

 

If you still didn't get it how to go further, then share the screenshots here to explain exact scenario.

answered
0

image.png

 

image.png

 

 

image.png

 

image.pnghere you can se my domain model + logic

answered