Commit 57e8681a40 for woocommerce
commit 57e8681a4097dfd0195b041d2dbc93df619ecbe1
Author: Mario Santos <34552881+SantosGuillamot@users.noreply.github.com>
Date: Fri Dec 12 01:53:21 2025 +0100
Fix: iAPI cart actions shouldn't be cached (#62403)
* Add `cache: 'no-store'` to API cart requests
* Add changefile(s) from automation for the following project(s): woocommerce
---------
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Luis Herranz <luisherranz@gmail.com>
diff --git a/plugins/woocommerce/changelog/62403-wooplug-5991-mini-cart-not-updating-with-1040 b/plugins/woocommerce/changelog/62403-wooplug-5991-mini-cart-not-updating-with-1040
new file mode 100644
index 0000000000..b688ca995d
--- /dev/null
+++ b/plugins/woocommerce/changelog/62403-wooplug-5991-mini-cart-not-updating-with-1040
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fix cached API request in iAPI cart store
\ No newline at end of file
diff --git a/plugins/woocommerce/client/blocks/assets/js/base/stores/woocommerce/cart.ts b/plugins/woocommerce/client/blocks/assets/js/base/stores/woocommerce/cart.ts
index 9d9267026f..f8f070ae8f 100644
--- a/plugins/woocommerce/client/blocks/assets/js/base/stores/woocommerce/cart.ts
+++ b/plugins/woocommerce/client/blocks/assets/js/base/stores/woocommerce/cart.ts
@@ -270,6 +270,7 @@ const { state, actions } = store< Store >(
`${ state.restUrl }wc/store/v1/cart/remove-item`,
{
method: 'POST',
+ cache: 'no-store',
headers: {
Nonce: state.nonce,
'Content-Type': 'application/json',
@@ -365,6 +366,7 @@ const { state, actions } = store< Store >(
`${ state.restUrl }wc/store/v1/cart/${ endpoint }`,
{
method: 'POST',
+ cache: 'no-store',
headers: {
Nonce: state.nonce,
'Content-Type': 'application/json',
@@ -449,6 +451,7 @@ const { state, actions } = store< Store >(
return {
method: 'POST',
path: `/wc/store/v1/cart/update-item`,
+ cache: 'no-store',
headers: {
Nonce: state.nonce,
'Content-Type': 'application/json',
@@ -477,6 +480,7 @@ const { state, actions } = store< Store >(
return {
method: 'POST',
path: `/wc/store/v1/cart/add-item`,
+ cache: 'no-store',
headers: {
Nonce: state.nonce,
'Content-Type': 'application/json',
@@ -489,6 +493,7 @@ const { state, actions } = store< Store >(
`${ state.restUrl }wc/store/v1/batch`,
{
method: 'POST',
+ cache: 'no-store',
headers: {
Nonce: state.nonce,
'Content-Type': 'application/json',
@@ -599,7 +604,11 @@ const { state, actions } = store< Store >(
try {
const res: Response = yield fetch(
`${ state.restUrl }wc/store/v1/cart`,
- { headers: { 'Content-Type': 'application/json' } }
+ {
+ method: 'GET',
+ cache: 'no-store',
+ headers: { 'Content-Type': 'application/json' },
+ }
);
const json: Cart = yield res.json();