Creating a Shopping Cart

Heliyabisadi shared this problem 4 months ago
In Progress

Hi

I am making a shopping cart. I have to data master. One has a product and the other includes the items added to cart. The problem is when I add the same item to cart, a new row is created but I want it to be added to the previous one. I have used conditions withe Filter and Has function but it does not work!

When name (in cart data master) HAS input_value (product name in product data master) the row is modified else a new row is created.

Also I have tried the above condition with Filter function. It didn't work similarly!

Regards

Helia

Comments (1)

photo
1

The conditions will be a bit more complicated than that. You'll need to have 2 possible events when you try to add an item to the cart - one that adds a new record to the data master and one that modifies the row.

For the event that adds a new row, the condition should look something like this:

2dffafaf729a48ad498357b383ac8ade

This expression first checks to make sure that the value you entered in the "Quantity" input text field is a number and that the number is greater than 0. Then, it checks to see if any of the products in the Cart data master are already within the Cart. It does this by filtering the cart down to its product names and seeing if any match the product field in the data grid/list with the products you can add to your cart. It then checks to see if the result of that filter is 0. If it is, that means no records match, so you can add a new record.


For the event that modifies the Data Master, the condition should look something like this:

b82509b670d6e8deebf78b8aae7682fc

It's similar to the last condition, checking to see if the value entered is a number and greater than 0. Then, it does the same filter, but just checks to see if that result is greater than 0, which means some records match.

The modify event itself should look something like this:

510e42de66bdf57e61ef9609395ad229

First, it filters the data master down to only the products that match. For the quantity, it filters down the data master to the product names that match and then selects the quantity from that row. Then, it adds the value you entered into the "Quantity" input text field onto that number.

We've attached the example file that these images are referencing.