Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TAS-2815] 🎨 Enable coupon code on all checkout pages #2000

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/components/NFTBook/CrossSellDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ import { getNFTBookPurchaseLink } from '~/util/api';
import { logTrackerEvent, logPurchaseFlowEvent } from '~/util/EventLogger';

import nftOrCollectionMixin from '~/mixins/nft-or-collection';
import couponMixin from '~/mixins/coupon';

export default {
name: 'NFTBookCrossSellDialog',
mixins: [nftOrCollectionMixin],
mixins: [nftOrCollectionMixin, couponMixin],
props: {
open: {
type: Boolean,
Expand Down Expand Up @@ -150,7 +151,9 @@ export default {
{
gaClientId: this.getGaClientId,
gaSessionId: this.getGaSessionId,
coupon: this.$route.query.coupon,
coupon: this.getApplicableCoupon({
checkoutPrice: customPriceInDecimal,
}),
customPriceInDecimal,
utmCampaign: this.utmCampaign,
utmSource: `${this.utmSource}_cross-sell`,
Expand Down
3 changes: 3 additions & 0 deletions src/constant/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,3 +452,6 @@ export const SEARCH_SUGGESTIONS = [
'信仰',
'邵家臻',
];

export const CHRISTMAS_CAMPAIGN_MIN_SPEND = 9;
export const CHRISTMAS_CAMPAIGN_COUPON = 'XMASREAD';
22 changes: 22 additions & 0 deletions src/mixins/coupon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {
CHRISTMAS_CAMPAIGN_MIN_SPEND,
CHRISTMAS_CAMPAIGN_COUPON,
} from '@/constant/index';

export default {
computed: {
mixinCoupon() {
return this.$route.query.coupon || '';
},
},
methods: {
getApplicableCoupon({ cartCoupon, checkoutPrice }) {
if (this.mixinCoupon || cartCoupon) {
return this.mixinCoupon || cartCoupon;
}
return checkoutPrice > CHRISTMAS_CAMPAIGN_MIN_SPEND
? CHRISTMAS_CAMPAIGN_COUPON
: '';
},
},
};
14 changes: 9 additions & 5 deletions src/pages/nft/class/_classId/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -426,24 +426,25 @@

<script>
import { mapActions, mapGetters } from 'vuex';
import { nftClassCollectionType, parseNFTMetadataURL } from '~/util/nft';
import { getNFTBookPurchaseLink, postNewStripeFiatPayment } from '~/util/api';
import { logTrackerEvent, logPurchaseFlowEvent } from '~/util/EventLogger';
import {
IS_TESTNET,
USD_TO_HKD_RATIO,
EXTERNAL_HOST,
NFT_BOOK_PLATFORM_LIKER_LAND,
LIKECOIN_API_BASE,
LIKECOIN_BUTTON_BASE,
} from '~/constant';
} from '@/constant/index';
import { nftClassCollectionType, parseNFTMetadataURL } from '~/util/nft';
import { getNFTBookPurchaseLink, postNewStripeFiatPayment } from '~/util/api';
import { logTrackerEvent, logPurchaseFlowEvent } from '~/util/EventLogger';

import nftMixin from '~/mixins/nft';
import clipboardMixin from '~/mixins/clipboard';
import crossSellMixin from '~/mixins/cross-sell';
import navigationListenerMixin from '~/mixins/navigation-listener';
import utmMixin from '~/mixins/utm';
import alertMixin from '~/mixins/alert';
import couponMixin from '~/mixins/coupon';

export default {
name: 'NFTClassDetailsPage',
Expand All @@ -454,6 +455,7 @@ export default {
navigationListenerMixin,
utmMixin,
alertMixin,
couponMixin,
],
layout: 'default',
asyncData({ query }) {
Expand Down Expand Up @@ -1424,7 +1426,9 @@ export default {
gaClientId,
gaSessionId,
giftInfo,
coupon: this.$route.query.coupon,
coupon: this.getApplicableCoupon({
checkoutPrice: edition.price,
}),
customPriceInDecimal,
utmCampaign: this.utmCampaign,
utmSource: this.utmSource,
Expand Down
6 changes: 5 additions & 1 deletion src/pages/nft/collection/_collectionId/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ import clipboardMixin from '~/mixins/clipboard';
import navigationListenerMixin from '~/mixins/navigation-listener';
import utmMixin from '~/mixins/utm';
import alertMixin from '~/mixins/alert';
import couponMixin from '~/mixins/coupon';

export default {
name: 'NFTCollectionDetailsPage',
Expand All @@ -120,6 +121,7 @@ export default {
navigationListenerMixin,
utmMixin,
alertMixin,
couponMixin,
],
layout: 'default',
data() {
Expand Down Expand Up @@ -533,7 +535,9 @@ export default {
gaClientId,
giftInfo,
gaSessionId,
coupon: this.$route.query.coupon,
coupon: this.getApplicableCoupon({
checkoutPrice: customPriceInDecimal,
}),
customPriceInDecimal,
utmCampaign: this.utmCampaign,
utmSource: this.utmSource,
Expand Down
17 changes: 6 additions & 11 deletions src/pages/shopping-cart/book.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,14 @@

import nftMixin from '~/mixins/nft';
import alertMixin from '~/mixins/alert';

const CHRISTMAS_CAMPAIGN_MIN_SPEND = 9;
const CHRISTMAS_CAMPAIGN_COUPON = 'XMASREAD';
import couponMixin from '~/mixins/coupon';

export default {
name: 'ShoppingCartPage',
filters: {
formatNumberWithUSD,
},
mixins: [nftMixin, alertMixin],
mixins: [nftMixin, alertMixin, couponMixin],
data() {
return {
isGiftDialogOpen: false,
Expand Down Expand Up @@ -251,12 +249,6 @@
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 @@ -387,7 +379,10 @@
fbClickId: this.fbClickId,
items: this.shoppingCartBookItems,
email: this.walletEmail,
coupon: this.getApplicableCoupon,
coupon: this.getApplicableCoupon({
cartCoupon: this.coupon,
checkoutPrice: this.totalNFTPriceInUSD,
}),
giftInfo,
},
{
Expand All @@ -408,7 +403,7 @@
throw new Error('Failed to get purchase link');
}
} catch (error) {
console.error(error);

Check warning on line 406 in src/pages/shopping-cart/book.vue

View workflow job for this annotation

GitHub Actions / CI

Unexpected console statement
this.alertPromptError(error);
}
},
Expand Down
Loading