From af95de222a2b28d67f2f626836ca656874e377c0 Mon Sep 17 00:00:00 2001 From: AuroraHuang22 Date: Thu, 19 Dec 2024 21:05:31 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Update=20coupon=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/locales/zh-Hant.json | 2 +- src/pages/shopping-cart/book.vue | 30 ++++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/locales/zh-Hant.json b/src/locales/zh-Hant.json index f74f85fb0..18acafbb0 100644 --- a/src/locales/zh-Hant.json +++ b/src/locales/zh-Hant.json @@ -990,7 +990,7 @@ "shopping_cart_empty_notice": "購物車是空的", "shopping_cart_empty_notice_button": "瀏覽書店", "shopping_cart_error_insufficient_balance": "餘額不足,你只有 {balance}", - "shopping_cart_list_coupon_title": "優惠(如適用)", + "shopping_cart_list_coupon_title": "優惠(如適用)", "shopping_cart_list_coupon_text": "將於下一步計算", "shopping_cart_list_header_item": "購物明細", "shopping_cart_list_header_price": "單價", diff --git a/src/pages/shopping-cart/book.vue b/src/pages/shopping-cart/book.vue index ccdc9a325..bbc225de5 100644 --- a/src/pages/shopping-cart/book.vue +++ b/src/pages/shopping-cart/book.vue @@ -79,7 +79,7 @@ {{ $t('shopping_cart_list_coupon_title') }}
{{ $t('shopping_cart_list_coupon_text') }}
@@ -154,6 +154,9 @@ import { getNFTBookCartPurchaseLink } from '~/util/api'; import nftMixin from '~/mixins/nft'; import alertMixin from '~/mixins/alert'; +const CHRISTMAS_CAMPAIGN_MIN_SPEND = 9; +const CHRISTMAS_CAMPAIGN_COUPON = 'XMASREAD'; + export default { name: 'ShoppingCartPage', filters: { @@ -228,9 +231,32 @@ export default { return totalPrice + (unitPrice * item.quantity || 0); }, 0); }, + totalItemPriceInUSD() { + return this.shoppingCartBookItems.reduce((totalPrice, item) => { + let itemPrice = 0; + if (item.collectionId) { + itemPrice = this.getNFTCollectionPriceByCollectionId( + item.collectionId + ); + } else { + const edition = this.getNFTBookStorePriceByClassIdAndIndex( + item.productId, + item.classId ? item.priceIndex : undefined + ); + itemPrice = edition?.price || 0; + } + return totalPrice + (itemPrice * item.quantity || 0); + }, 0); + }, formattedFiatPrice() { return formatNumberWithUSD(this.totalNFTPriceInUSD); }, + getApplicableCoupon() { + if (this.coupon) return this.coupon; + return this.totalItemPriceInUSD > CHRISTMAS_CAMPAIGN_MIN_SPEND + ? CHRISTMAS_CAMPAIGN_COUPON + : ''; + }, }, mounted() { logPurchaseFlowEvent(this, 'view_cart', this.purchaseEventParams); @@ -361,7 +387,7 @@ export default { fbClickId: this.fbClickId, items: this.shoppingCartBookItems, email: this.walletEmail, - coupon: this.coupon || 'CHRISTMAS10', + coupon: this.getApplicableCoupon, giftInfo, }, {