Cart total not calculating properly

I’m building an eCommerce app for my friend’s design company.

For example one of his items are custom hoodies. I first started by making a Category collections with “Clothing” that leads to a Product collections (Hoodies) which then led to a Menu Item collections with each size (S-M-L-XL) was having it own separate Menu Item. The picture below shows my old template but imagine a list of each item size going on and on.

screenshot3

My databases were set up similar to the Food Truck template. The process would first create an “Order” and then show the customers the Menu Item list and each selection would create it’s own “Order Item” when the customer selected it. This worked for straight purchases but I had no cart and no way to “continue shopping” and save for later.

I tried to redesign the process and add a cart like the eCommerce clone app.
I created a new products page that lets you see one product option (Hoodies) at a time with a drop down menu giving you options of sizes/colors etc. I think this renders my Menu Items collection useless because I created a two separate Size and Color collections that link straight to the Products collections. I added a text box and button to enter the quantity and add to cart. My cart database has a quantity property linked to the product item.

My main issue is that I can’t seem to get the right formula to calculate the cart subtotal properly. Before I redesigned my app it was fine because the Order total would just calculate the sum of the Order Items but if a customer for example ordered 10 Small Hoodies… Small Hoodie would appear 10 times in the Order List.

Now I don’t have separate order items because I want my cart to show Small Hoodie once with a Quantity value next to it. Everything is fine when I have one Product type in the cart. The problem is when I have 2 separate product types (example 10 hoodies and 10 polos), the cart subtotal is way off.
My custom Formula is this: (Logged in User > Cart > Price > Sum) x (Logged in user > Cart > Quantity > Sum)

This is my formula.

The picture below is my new cart with one item, a quantity value and the subtotal costs working out.

In this other picture below as you can see, as soon as I add a 2nd Product type, it completely miscalculates the total because of the Cart > Quantity > Sum in my custom formula. The subtotal should be 174.93 for 7 hoodies, instead it appears as 349.86 which is way off.

I have no idea how to fix it. I need some advice please help me!

Hi! I have the same issue, i asked @Franklin (the one who developed the template) in DM. Let’s share the answers!

Thank you so much, I hope he gets back to us soon!

1 Like

If you notice that the sum you are getting is exactly double the expected sum, it can indicate what the problem may be. According to your formula there, my guess is that the total of the “Sum Quantity” here is equal to 2. Instead of 1. Which is why the amount is doubled.

2 Likes

Actually the issue is that “sum price” is the sum of all prices and “sum quantity” is the sum of all quantities.
In this case (sum price)x(sum quantity) = (24.99+24.99)x(5+2)
Although it should be the sum of each line (24.99x5)+(24.99x2)+…

1 Like

Thank you I understand now.

How would I write the custom formula so that it reads each line separately?

Good question :slight_smile: , i understood the issue, but i can’t figure out how to write the right formula :frowning_face:
That’s why i also need some help!
Besides it’s gonna be useful for everyone to update the template.

yeah because without this, it makes the whole template and half the databases useless.
The size and color database become useless and we’ll need to revert to separate menu items for each size which is pretty amateurish once I upload it to the iOS store.

Hi! I found a solution but i don’t know if it will work for you (on my side i don’t have any style and size) so below what i did:
-I created a new field in cart (panier) named “pre total” which calculate (PricexQuantity)
-And then in the cart to get the total cost i put “sum pre total”.
To sum up, first step i created a new field to calculate the price of a line and second step i made the sum of all this lines.
Hopefully it can help you :slight_smile:

Hello,

Thank you for using my template! Sorry, that the sum hasn’t been working. I will start using the Forum more as I was only on slack. I will take a look at the template and get back to you.

Thank you so much Franklin! We’ll await your response!

I have taken a look into the app and was having trouble with the quantity and total price before. I’m not to sure what custom formula to display ( Merch item x the amount of quantity = total for that item then repeat with all cart items. ) If anyone has any suggestions that would be great. At the moment sum price x sum quantity is doubling everything.