Skip to content

Instantly share code, notes, and snippets.

@enappd
Last active July 30, 2019 12:23
addToCart() {
this.storage.get(`product_${this.product.id}`).then(async data => {
if (data) {
const toast = await this.toast.create({
message: 'Item already in Cart',
duration: 2000
});
toast.present();
} else {
const toast = await this.toast.create({
message: 'Added to Cart',
duration: 2000
});
toast.present();
this.storage
.set(`product_${this.product.id}`, JSON.stringify(this.product))
.then(() => {
this.fun.updateCartBadge();
});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment