This commit is contained in:
David Remer 2020-04-06 11:16:18 +03:00
parent 7fd57b9393
commit 005a55c213
62 changed files with 905 additions and 751 deletions

View file

@ -1,12 +1,14 @@
class UpdateCart {
constructor(endpoint, nonce) {
constructor(endpoint, nonce)
{
this.endpoint = endpoint;
this.nonce = nonce;
}
update(onResolve, product, qty, variations) {
return new Promise( (resolve, reject) => {
update(onResolve, product, qty, variations)
{
return new Promise((resolve, reject) => {
fetch(
this.endpoint,
{
@ -20,18 +22,17 @@ class UpdateCart {
}
).then(
(result) => {
return result.json();
return result.json();
}
).then((result) => {
if (! result.success) {
reject(result.data);
return;
}
).then( (result) => {
if (! result.success) {
reject(result.data);
return;
}
const resolved = onResolve(result.data);
resolve(resolved);
}
)
})
});
}
}