# Payment info in the e-commerce template is messed up!

Hey everyone! I’ve cloned the e-commerce template and everything was super fine until I met this payment information section on the way to checkout. A custom formula is used to view the cost of the order and it’s literally showing the product of “the sum of all the cart’s price” with “sum of all the cart’s quantity”. I don’t know how to multiply each cart’s price with it’s quantity and showing the sum of all cart’s total price. I’ve attached the screenshots below! And also the template’s link. If anyone has any idea on solving this please let me know. I’ve been trying to solve this for the past 2 days!!!

Hi @kchan,

With these formulas you will not get a correct result: you sum up all the prices for the items, and then multiply them by total quantity of the items. Of course this is not correct - imagine you have 10 socks worth \$10 and one fur coat worth \$5,000. Total price is \$5,100; but using your method, you’ll get (\$10+\$5000) * (10 + 1) = \$55,110.

What I could suggest is creating a cart in a way, that you have shopping cart and a separate cart “line items” collection, with M:1 relationship to shopping cart.

In Line Items, in turn, there should be: Name, price per Unit, Quantity and Total Price for Unit.
Then, upon checkout, you could easily calculate Order Total by summing up Total Prices for line items (for current Shopping Cart’s Line Items).

Best regards, Victor.

Hey @Victor thanks for your help. I solved this by making my app’s database same as the adalo food odering app!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.