You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the autoSetNewCartAddresses is enabled, and you've set a default primary address in your account (yes this only applies when you are logged in), it is possible to create multiple empty carts on refresh.
This default code from the example folder:
{% if cart is not defined %}
{% set cart = craft.commerce.carts.cart %}
{% endif %}
is creating multiple carts when you have the autoSetNewCartAddresses setting enabled and you've setup a default primary address. This happens when you refresh several times in a row. You have to refresh fast but apparently customers are doing this because we are seeing multiple empty carts in our shop.
This only happens when the user has no active carts.
When debugging I found out that this is caused because of the autoSetNewCartAddresses setting. This is causing a save on first reload when you have no active cart. So when reloading multiple times it creates multiple carts:
Steps to reproduce
Do a clean install with craft 4.x and copy the commerce example-templates
Create a account and log in.
Set a default primary address
Open a tab with the /shop/ page.
Clear all active carts
Go to the /shop/ tab and refresh fast, like multiple times per second
You will see multiple empty active carts in the control panel tied to the same user.
Expected behavior
The expected behavior is that Craft Commerce only creates 1 cart.
Actual behavior
Craft Commerce creates multiple empty carts.
Craft CMS version
4.12.6.1
Craft Commerce version
4.6.13
PHP version
8.2
Operating system and version
Mac os 14.5
Database type and version
Mysql 8
Image driver and version
No response
Installed plugins and versions
The text was updated successfully, but these errors were encountered:
What happened?
Description
When the autoSetNewCartAddresses is enabled, and you've set a default primary address in your account (yes this only applies when you are logged in), it is possible to create multiple empty carts on refresh.
This default code from the example folder:
is creating multiple carts when you have the autoSetNewCartAddresses setting enabled and you've setup a default primary address. This happens when you refresh several times in a row. You have to refresh fast but apparently customers are doing this because we are seeing multiple empty carts in our shop.
This only happens when the user has no active carts.
When debugging I found out that this is caused because of the autoSetNewCartAddresses setting. This is causing a save on first reload when you have no active cart. So when reloading multiple times it creates multiple carts:
Steps to reproduce
Expected behavior
The expected behavior is that Craft Commerce only creates 1 cart.
Actual behavior
Craft Commerce creates multiple empty carts.
Craft CMS version
4.12.6.1
Craft Commerce version
4.6.13
PHP version
8.2
Operating system and version
Mac os 14.5
Database type and version
Mysql 8
Image driver and version
No response
Installed plugins and versions
The text was updated successfully, but these errors were encountered: