Fix product page orders considering shipping costs

This commit is contained in:
Pedro Silva 2023-10-30 14:27:42 +00:00
parent 2b9ac48616
commit 5d885809f7
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
6 changed files with 34 additions and 15 deletions

View file

@ -143,7 +143,7 @@ class SingleProductActionHandler {
{
this.cartHelper = null;
return (data, actions) => {
return (data, actions, options = {}) => {
this.errorHandler.clear();
const onResolve = (purchase_units) => {
@ -178,7 +178,7 @@ class SingleProductActionHandler {
});
};
return this.updateCart.update(onResolve, this.getProducts());
return this.updateCart.update(onResolve, this.getProducts(), options.updateCartOptions || {});
};
}

View file

@ -11,9 +11,10 @@ class UpdateCart {
*
* @param onResolve
* @param {Product[]} products
* @param {Object} options
* @returns {Promise<unknown>}
*/
update(onResolve, products)
update(onResolve, products, options = {})
{
return new Promise((resolve, reject) => {
fetch(
@ -27,6 +28,7 @@ class UpdateCart {
body: JSON.stringify({
nonce: this.nonce,
products,
...options
})
}
).then(