Skip to content

Commit 3bd2f0c

Browse files
committed
Use correct key for 'quantity' in add-item API call (#3875)
* Use correct key for 'quantity' in add-item API call * Add changelog and readme entries
1 parent 2ae0cff commit 3bd2f0c

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*** Changelog ***
22

33
= 9.2.0 - xxxx-xx-xx =
4+
* Fix - Fix the quantity parameter for the express checkout add-to-cart API call.
45
* Dev - Replaces part of the StoreAPI call code for the cart endpoints to use the newly introduced filter.
56
* Fix - Clear cart first when using express checkout inside the product page.
67
* Fix - Avoid Stripe timeouts for the express checkout click event.

client/api/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,17 @@ export default class WCStripeAPI {
524524
* @return {Promise} Promise for the request to the server.
525525
*/
526526
expressCheckoutAddToCart( productData ) {
527+
// Rename qty to quantity to match StoreAPI expected parameter.
528+
const { qty, ...rest } = productData;
529+
const quantity = qty ?? 1;
530+
const blocksApiProductData = {
531+
...rest,
532+
quantity,
533+
};
534+
527535
const data = applyFilters(
528536
'wcstripe.express-checkout.cart-add-item',
529-
productData
537+
blocksApiProductData
530538
);
531539
return this.postToBlocksAPI( '/wc/store/v1/cart/add-item', data );
532540
}

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
111111
== Changelog ==
112112

113113
= 9.2.0 - xxxx-xx-xx =
114+
* Fix - Fix the quantity parameter for the express checkout add-to-cart API call.
114115
* Dev - Replaces part of the StoreAPI call code for the cart endpoints to use the newly introduced filter.
115116
* Fix - Clear cart first when using express checkout inside the product page.
116117
* Fix - Avoid Stripe timeouts for the express checkout click event.

0 commit comments

Comments
 (0)