Skip to content

Commit

Permalink
Update toolkit for Paper v7.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
DrJulik committed Feb 28, 2024
1 parent 6b62495 commit f396d55
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/ts/cart/cart.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,41 @@
import { Product } from "../models.interface";
export const cart = {

updateCartNote(note: string) {
this.cart_loading = true;
fetch(`${window.Shopify.routes.root}cart/update.js`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ note: note }),
})
.then(async (response) => {
let data = await response.json();

// good response
if (response.status === 200) {
this.cart.items = data.items.map((item: Product) => {
return {
...item,
};
});
this.updateCart(false);
}

// error response
else {
(this.error_title = data.message),
(this.error_message = data.description),
(this.show_alert = true);
}
})
.catch((error) => {
console.error("Error:", error);
this.cart_loading = false;
});
},

// Update cart with fetched data
async updateCart (
openCart: boolean
Expand Down

0 comments on commit f396d55

Please sign in to comment.