drhenner / ror_ecommerce

Ruby on Rails Ecommerce platform, perfect for your small business solution.
www.ror-e.com
MIT License
1.21k stars 409 forks source link

Can create a submitted order with total charged not matching items associated with order. #174

Closed TWarszawski closed 7 years ago

TWarszawski commented 8 years ago

When a customer begins check out and finishes checkout in a different window concurrently, the order total may not accurately reflect the products in the order.

Steps to reproduce:

  1. Start site, create a customer, create/pick test product.
  2. Have the customer add the product to the cart and go through checkout up until the complete order step.
  3. In a separate tab or window, log in again as the customer and go to the cart page.
  4. Have the customer on the cart page update the quantity in the cart.
  5. Begin checkout from the cart page and finish checkout (click the Complete Order button) as close to the same time as possible.

Expected Result: The amount charged matches the sum of the totals for each item in the cart.

Actual Result: The amount charged reflects the total of the original items in the cart, but when examining the order page the updated items are shown to be associated with the order.

drhenner commented 8 years ago

@TWarszawski Thanks for the details. I'm in over my head with work but I'll try to get this solved as soon as possible.

I'm thinking the best fix is to validate that the quantities in the cart and the price of the cart matches order_items when you have. If not return to the checkout page with a validation error.

Even more preferred would be to checkout with the items you are currently viewing but that could be difficult. If it isn't too hard I'll go with this option.

drhenner commented 7 years ago

@sullivanLi feel free to give this bug a try. This solution shouldn't try anything too fancy. It's possible to create a complex solution here that does cool stuff but simple is best IMO.

drhenner commented 7 years ago

Solved by @sullivanLi Thank you