Closed Web10-Joris closed 1 month ago
Sorry, I'm unable to reproduce this issue.
Whenever I provide the email for an existing customer, it uses the existing customer rather than creating a new one, as expected. 🤔
Does the email you entered match exactly with the email of the existing customer in the database? Is the casing the same or different?
How are you providing the customer information? Can you provide the payload you're submitting to the endpoint?
Hi Duncan,
The emails are an exact match. Customer information is sent to /!/simple-commerce/cart
with this body:
{
"_token": "bgp7mte25uc1gUPzbWCpV8VkXIvw3EE4PIum0F7u",
"_redirect": "/checkout/offsite/mollie",
"_error_redirect": "/checkout",
"_request": null,
"name": "Name",
"customer": {
"phone": "1345678"
},
"email": "email@example.com",
"shipping_name": null,
"shipping_address": "street",
"shipping_address_line2": "street2",
"shipping_city": "city",
"shipping_postal_code": "postal",
"shipping_country": "NL",
"use_shipping_address_for_billing": null
}
Looks like it is inserting the customer twice in a very short amount of time (within 1-2 sec), causing the second attempt to fail. Since this is the already existing record:
{
"data":
[
{
"id": 183,
"name": "Name",
"email": "email@example.com",
"phone": "1345678",
"data": "{\"published\": true}",
"created_at": "2024-04-13 21:22:55",
"updated_at": "2024-04-13 21:22:55"
}
]
}
and this is the SQL statement of the error:
insert into
`customers` (`email`, `data`, `updated_at`, `created_at`)
values
(
email@example.com,
{ "published": true },
2024 -04 -13 21: 22: 55,
2024 -04 -13 21: 22: 55
)
They both have the same updated_at
& created_at
datetime. So probably my axios script is sending the data too quickly, is that possible? (it only sends it after the user changes Country or Region fields). Causing the HandlesCustomerInformation
to create a new customer because it could not found one, while the other execution is injecting it into the database? Otherwise I also don't know where this could come from...
Hmm, are you sending multiple requests to the server at the same time? There must be some kind of race condition happening.
I continue to receive these errors intermittently and am unsure where it comes from. I'll close this issue for now. I'm in the process of building a new store and will monitor to see if the issue also shows up there.
Description
It looks like the findOrCreateCustomer tries to create customers in the database with already existing emails.
Stacktrace:
Steps to reproduce
Environment
Environment Application Name: example Laravel Version: 10.47.0 PHP Version: 8.2.15 Composer Version: 2.7.2 Environment: production Debug Mode: OFF URL: example.nl Maintenance Mode: OFF
Cache Config: CACHED Events: NOT CACHED Routes: CACHED Views: CACHED
Drivers Broadcasting: log Cache: statamic Database: mysql Logs: stack / daily, flare Mail: smtp Queue: sync Session: file
Simple Commerce Currencies: EUR, EUR, EUR, EUR Gateways: Mollie Repository: Customer: DuncanMcClean\SimpleCommerce\Customers\EloquentCustomerRepository Repository: Order: DuncanMcClean\SimpleCommerce\Orders\EloquentOrderRepository Repository: Product: DuncanMcClean\SimpleCommerce\Products\EntryProductRepository Shipping Methods: MTC Pallet Zending, PostNL International Tax Engine: DuncanMcClean\SimpleCommerce\Tax\Standard\TaxEngine
Statamic Addons: 7 Antlers: runtime Sites: 4 (Nederlands, Duits, Engels, Pools) Stache Watcher: Enabled Static Caching: Disabled Version: 4.52.0 PRO
Statamic Addons aerni/advanced-seo: 2.4.4 duncanmcclean/simple-commerce: 6.0.10 heidkaemper/statamic-toolbar: 1.1.2 statamic-rad-pack/runway: 6.4.1 statamic/collaboration: 0.8.1 web10/back-in-stock-notifier: dev-main web10/language-switcher: dev-main