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.
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!