duncanmcclean / simple-commerce

A simple, yet powerful e-commerce addon for Statamic.
https://statamic.com/addons/duncanmcclean/simple-commerce
Other
146 stars 40 forks source link

Bug in shopping cart #855

Closed yaser2490 closed 1 year ago

yaser2490 commented 1 year ago

Description

Hello I think I found a bug in the shopping cart In normal case, when the stock of the product is, for example, 2, and if I add the product to the basket 3 times, it will be added!

my English is not good :( Example: My product stock = 1

<form>
    <input name="quantity" value="3"/> //quantity = 3
    <button>Add To Cart</button> //One time click (Add To Cart) and its OK, got error for stock
</form>

Bug is here: My product stock = 1

<form>
    <input name="quantity" value="1"/> //quantity = 1
    <button>Add To Cart</button>  //2 time click (Add To Cart) and its OK too, not got error for stock. cart count is 2 but must be 1
</form>

Steps to reproduce

:)

Environment

Environment Application Name: Statamic Laravel Version: 9.52.4 PHP Version: 8.1.12 Composer Version: 2.5.1 Environment: local Debug Mode: ENABLED URL: statabit.test Maintenance Mode: OFF

Cache Config: NOT CACHED Events: NOT CACHED Routes: NOT CACHED Views: CACHED

Drivers Broadcasting: log Cache: statamic Database: mysql Logs: stack / single Mail: smtp Queue: sync Session: file

Simple Commerce Currencies: USD Gateways: Dummy Repository: Customer: DoubleThreeDigital\SimpleCommerce\Customers\EntryCustomerRepository Repository: Order: DoubleThreeDigital\SimpleCommerce\Orders\EntryOrderRepository Repository: Product: DoubleThreeDigital\SimpleCommerce\Products\EntryProductRepository Shipping Methods: Standard Post Tax Engine: DoubleThreeDigital\SimpleCommerce\Tax\BasicTaxEngine

Statamic Addons: 2 Antlers: runtime Stache Watcher: Enabled Static Caching: Disabled Version: 3.4.5 PRO

Statamic Addons doublethreedigital/guest-entries: 2.1.1 doublethreedigital/simple-commerce: 4.5.8

duncanmcclean commented 1 year ago

Are you clicking the 'Add to cart' button multiple times? It's recommended that you disable the button while the form's being submitted.

yaser2490 commented 1 year ago

No, I did not double click while submitting the form I clicked once and it was added to the cart. I clicked a second time and it was added again (is the product inventory checked here?) In all conditions, the quantity = 1 Do I need to send a video?

duncanmcclean commented 1 year ago

Do I need to send a video?

Yes please, I'm struggling to replicate myself.

Simple Commerce will re-check product stock during checkout anyway so they won't be charged for an order if there's not enough stock to fulfil it.

yaser2490 commented 1 year ago

screen-capture (3).webm

I use "sc:cart:addItem" tag for adding to cart.

duncanmcclean commented 1 year ago

Did you manage to get this sorted?

yaser2490 commented 1 year ago

Yes. I used sc:cart:addItem and after i used sc:cart:updateItem.