Skip to content

Commit

Permalink
🔀 Merge #1990 into deploy/rinkeby
Browse files Browse the repository at this point in the history
  • Loading branch information
AuroraHuang22 committed Dec 19, 2024
2 parents b471d61 + af95de2 commit 9246926
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/locales/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,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": "單價",
Expand Down
30 changes: 28 additions & 2 deletions src/pages/shopping-cart/book.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
{{ $t('shopping_cart_list_coupon_title') }}
</div>
<div
class="col-span-3 sm:col-span-2 text-medium-gray text-[14px] font-200"
class="col-span-3 sm:col-span-2 text-medium-gray text-[14px] font-400"
>
{{ $t('shopping_cart_list_coupon_text') }}
</div>
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -361,7 +387,7 @@ export default {
fbClickId: this.fbClickId,
items: this.shoppingCartBookItems,
email: this.walletEmail,
coupon: this.coupon || 'CHRISTMAS10',
coupon: this.getApplicableCoupon,
giftInfo,
},
{
Expand Down

0 comments on commit 9246926

Please sign in to comment.