From 79822d45a7a3e330ee2af8eb6f123e65afc78b8c Mon Sep 17 00:00:00 2001 From: William Chong Date: Fri, 27 Sep 2024 18:13:43 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Fetch=20cart=20coupon=20from=20item?= =?UTF-8?q?s=20if=20qs=20not=20set?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/shopping-cart/book.vue | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/pages/shopping-cart/book.vue b/src/pages/shopping-cart/book.vue index 77eee337f..b2e91ee0a 100644 --- a/src/pages/shopping-cart/book.vue +++ b/src/pages/shopping-cart/book.vue @@ -165,6 +165,15 @@ export default { 'shoppingCartBookProductList', 'shoppingCartBookItems', ]), + coupon() { + if (this.$route.query.coupon) { + return this.$route.query.coupon; + } + // stripe only support one coupon + const firstCoupon = this.shoppingCartBookItems.find(item => item.coupon) + .coupon; + return firstCoupon || ''; + }, purchaseEventParams() { let { locale } = this.$i18n; if (locale === 'zh-Hant') { @@ -333,7 +342,7 @@ export default { gadSource: this.gadSource, items: this.shoppingCartBookItems, email: this.walletEmail, - coupon: this.$route.query.coupon, + coupon: this.coupon, giftInfo, }); if (url) {