${function() {
Object.keys(data[0]).forEach((key) => {
data[key] = data[0][key];
});
return '';
}()}
${function() {
const template_name = 'register';
const benefit_card_setting_Obj = data[1]?.settings;
let benefit_card_setting = {};
switch (template_name) {
case 'login':
case 'register':
benefit_card_setting = benefit_card_setting_Obj['login'] || {};
break;
case 'product':
benefit_card_setting = benefit_card_setting_Obj['product'] || {};
break;
case 'collection':
benefit_card_setting = benefit_card_setting_Obj['collection'] || {};
break;
default:
benefit_card_setting = benefit_card_setting_Obj['default'] || {};
break;
}
let default_benefit_card_setting = {
title: `Sign up as a member and get {{.discount}} and {{.point_count}}{{.point_name}} immediately`,
title_default: `Register to become a member and enjoy benefits immediately`,
display_deduction_text: true,
border_color: '255,239,222',
bg_color_left: '250,173,112',
bg_color_right: '250,100,89',
text_color: '255,255,255',
};
if (template_name != 'login' && template_name != 'register') {
default_benefit_card_setting = {
...default_benefit_card_setting,
display_points: true,
display_deduction: true,
display_discount_code: true,
btn_text_color: '250,101,90',
btn_bg_color: '255,241,224',
btn_text: `Join now`,
}
}
data['benefit_card_setting'] = {
...default_benefit_card_setting,
...benefit_card_setting,
title: benefit_card_setting.title || default_benefit_card_setting.title,
title_default: benefit_card_setting.title_default || default_benefit_card_setting.title_default,
btn_text: benefit_card_setting.btn_text || default_benefit_card_setting.btn_text,
};
return '';
}()}
${function(){
const {
title,
title_default,
} = data.benefit_card_setting;
const getTitleDom = function(discount_code, point){
return ` `;
};
let content = getTitleDom('', '');
const { benefits = [] } = data.memberDetail?.current_tier || {};
let pointBenefits = benefits.filter((benefit) => {
return benefit.trigger_type === 'upgrade' && benefit.benefit_type === 'point';
});
let discountCodeBenefits = benefits.filter((benefit) => {
return benefit.trigger_type === 'upgrade' && benefit.benefit_type === 'discount_code';
});
let discountCodeName = '';
let discountCodeType = '';
if(discountCodeBenefits.length > 0) {
let benefit = discountCodeBenefits[0];
const percentageBenefits = discountCodeBenefits.filter((benefit) => {
return benefit.reward?.discount_code_activity.discount_type === 'percentage';
});
const fixedAmountBenefits = discountCodeBenefits.filter((benefit) => {
return benefit.reward?.discount_code_activity.discount_type === 'fixed_amount';
});
const buyXGetYBenefits = discountCodeBenefits.filter((benefit) => {
return benefit.reward?.discount_code_activity.discount_type === 'buy_x_get_y';
});
const freeShippingBenefits = discountCodeBenefits.filter((benefit) => {
return benefit.reward?.discount_code_activity.discount_type === 'free_shipping';
});
if (percentageBenefits.length > 0) {
benefit = percentageBenefits.reduce((accumulator, current) => {
return +accumulator.reward?.discount_code_activity.discount_value > +current.reward?.discount_code_activity.discount_value ? accumulator : current;
}, percentageBenefits[0]);
discountCodeType = 'percentage';
discountCodeName = `${benefit.reward?.discount_code_activity.discount_value}% OFF`;
} else if (fixedAmountBenefits.length > 0) {
benefit = fixedAmountBenefits.reduce((accumulator, current) => {
return +accumulator.reward?.discount_code_activity.discount_value > +current.reward?.discount_code_activity.discount_value ? accumulator : current;
}, fixedAmountBenefits[0]);
discountCodeType = 'fixed_amount';
discountCodeName = ` `;
} else if (buyXGetYBenefits.length > 0) {
let buyXGetYFreeBenefits = buyXGetYBenefits.filter(benefit => benefit.reward?.discount_code_activity.obtain_product.obtain_type === 'free');
let buyXGetYPercentageBenefits = buyXGetYBenefits.filter(benefit => benefit.reward?.discount_code_activity.obtain_product.obtain_type === 'percentage');
let buyXGetYFixedAmountBenefits = buyXGetYBenefits.filter(benefit => benefit.reward?.discount_code_activity.obtain_product.obtain_type === 'fixed_amount');
if(buyXGetYFreeBenefits.length > 0) {
benefit = buyXGetYFreeBenefits[0];
if(benefit.reward?.discount_code_activity.prerequisite_type === 'subtotal') {
discountCodeName = `Buy Get ${benefit.reward?.discount_code_activity.obtain_product.product_count} Free`;
}else if (benefit.reward?.discount_code_activity.prerequisite_type === 'quantity') {
discountCodeName = `Buy ${benefit.reward?.discount_code_activity.prerequisite_value} Get ${benefit.reward?.discount_code_activity.obtain_product.product_count} Free`;
}
} else if (buyXGetYPercentageBenefits.length > 0) {
benefit = buyXGetYPercentageBenefits.reduce((accumulator, current) => {
return +accumulator.reward?.discount_code_activity.obtain_product.obtain_value > +current.reward?.discount_code_activity.obtain_product.obtain_value ? accumulator : current;
}, buyXGetYPercentageBenefits[0]);
discountCodeName = `${benefit.reward?.discount_code_activity.obtain_product.obtain_value}% OFF`;
}else if (buyXGetYFixedAmountBenefits.length > 0) {
benefit = buyXGetYFixedAmountBenefits.reduce((accumulator, current) => {
return +accumulator.reward?.discount_code_activity.obtain_product.obtain_value > +current.reward?.discount_code_activity.obtain_product.obtain_value ? accumulator : current;
}, buyXGetYFixedAmountBenefits[0]);
discountCodeName = ` `;
}
discountCodeType = 'buy_x_get_y';
} else if(freeShippingBenefits.length > 0) {
discountCodeName = ``;
discountCodeType = 'free_shipping';
}
}
if (pointBenefits.length === 0 && discountCodeBenefits.length > 0) {
if(discountCodeType !== 'free_shipping') {
content = getTitleDom(discountCodeName, '');
}
}
let benefitPointSum = 0;
if(pointBenefits.length > 0) {
benefitPointSum = pointBenefits.reduce((accumulator, benefit) => {
return Number(accumulator) + Number(benefit.reward.point_value);
}, 0);
}
if (pointBenefits.length > 0 && discountCodeBenefits.length === 0) {
content = getTitleDom('', benefitPointSum);
}
if (pointBenefits.length > 0 && discountCodeBenefits.length > 0) {
if(discountCodeType !== 'free_shipping') {
content = getTitleDom(discountCodeName, benefitPointSum);
} else {
content = getTitleDom('', benefitPointSum);
}
}
if (pointBenefits.length === 0 && discountCodeBenefits.length === 0) {
const { campaigns } = data.pointPlans || {};
const pointSum = campaigns?.filter(({campaign}) => {
return campaign.event_type === 'become_member';
}).reduce((accumulator, {campaign}) => {
return accumulator + campaign.campaign_rule.reward_points;
}, 0);
if (pointSum > 0) {
content = getTitleDom('', pointSum);
}
}
return `
${content}
`;
}()}
${function(){
const { campaign } = data.pointsDeduction || {};
if(!campaign?.campaign_id) {
return '';
}
let content = '';
if(campaign?.max_deduction && campaign?.deduction_rate?.points) {
const points = Math.ceil(Number(campaign.max_deduction) * Number(campaign.deduction_rate.points));
content = `New members can use up to to deduct on each order`;
}else {
const { benefits = [] } = data.memberDetail?.current_tier || {};
let pointBenefits = benefits.filter((benefit) => {
return benefit.trigger_type === 'upgrade' && benefit.benefit_type === 'point';
});
let benefitPointsValue = 0;
if(pointBenefits.length > 0) {
benefitPointsValue = pointBenefits.reduce((accumulator, benefit) => {
return Number(accumulator) + Number(benefit.reward.point_value);
}, 0);
}
const { campaigns } = data.pointPlans || {};
const campaignPointsValue = campaigns?.filter(({campaign}) => {
return campaign.event_type === 'become_member';
}).reduce((accumulator, {campaign}) => {
return accumulator + campaign.campaign_rule.reward_points;
}, 0);
let currentPoints = benefitPointsValue || campaignPointsValue;
if(currentPoints > 0) {
let amount = currentPoints / Number(campaign.deduction_rate.points);
content = `New members can use points to deduct up to on their first order`;
}else {
content = ` can be offset against `;
}
}
return `
${content}
`;
}()}
${function(){
if (data.benefit_card_setting.display_discount_code && !data.pointsDeduction?.campaign?.campaign_id && !!data.coupon_recommendation?.activity && !!data.coupon_recommendation?.can_use) {
return `
`;
}
if (!!data.pointsDeduction?.campaign?.campaign_id && !!data.coupon_recommendation?.activity && !!data.coupon_recommendation?.can_use) {
return `
`;
}
if ((data.benefit_card_setting.display_points || data.benefit_card_setting.display_deduction) && !!data.pointsDeduction?.campaign?.campaign_id && (!data.coupon_recommendation?.activity || !data.coupon_recommendation?.can_use)) {
return `
`;
}
if (!data.pointsDeduction?.campaign?.campaign_id && !!data.coupon_recommendation?.activity && !data.coupon_recommendation?.can_use) {
return `
`;
}
return '';
}()}
${function(){
const {activity, discount_code} = data.coupon_recommendation || {};
const {discount_type, discount_value, prerequisite_value, prerequisite_type, obtain_product} = activity || {};
let text = '';
if(discount_type === 'percentage') {
if (prerequisite_type === 'none') {
text = `Order now to enjoy ${discount_value}% OFF. Click to copy the discount code: `;
}
if (prerequisite_type === 'quantity') {
text = `Get ${discount_value}% OFF your entire order when you purchase ${parseInt(prerequisite_value)} or more. Click to copy the discount code: `;
}
if (prerequisite_type === 'subtotal') {
text = `Spend to enjoy ${discount_value}% OFF on your entire order. Click to copy the discount code: `;
}
}else if(discount_type === 'fixed_amount') {
if (prerequisite_type === 'none') {
text = `Order now to get an instant discount of . Click to copy the discount code: `;
}
if (prerequisite_type === 'quantity') {
text = `Get an instant discount when you purchase ${parseInt(prerequisite_value)} items. Click to copy the discount code: `;
}
if (prerequisite_type === 'subtotal') {
text = `Spend to get an instant discount of . Click to copy the discount code: `;
}
} else if(discount_type === 'free_shipping') {
if (prerequisite_type === 'none') {
text = `Order now to enjoy free shipping. Click to copy the discount code: `;
}
if (prerequisite_type === 'quantity') {
text = `Free shipping on orders of ${parseInt(prerequisite_value)} items or more. Click to copy the discount code: `;
}
if (prerequisite_type === 'subtotal') {
text = `Spend to enjoy free shipping. Click to copy the discount code: `;
}
} else if(discount_type === 'buy_x_get_y') {
const x = prerequisite_value;
const y = obtain_product.product_count;
const obtain_value = obtain_product.obtain_value;
if(obtain_product.obtain_type === 'free') {
if (prerequisite_type === 'quantity') {
text = `Purchase the current product and enjoy a buy ${x} get ${y} Free offer. Click to copy the discount code: `;
} else if (prerequisite_type === 'subtotal') {
text = `Purchase the current product and enjoy a buy get ${y} Free offer. Click to copy the discount code: `;
}
}
if(obtain_product.obtain_type === 'percentage') {
if (prerequisite_type === 'quantity') {
text = `Purchase ${x} and enjoy an additional ${obtain_value}% OFF when you buy more than ${y}. Click to copy the discount code: `;
} else if (prerequisite_type === 'subtotal') {
text = `Purchase and enjoy an additional ${obtain_value}%% OFF when you buy more than ${y}. Click to copy the discount code: `;
}
}
if(obtain_product.obtain_type === 'fixed_amount') {
if (prerequisite_type === 'quantity') {
text = `Purchase ${x}, and enjoy a discount when you buy an additional ${y}. Click to copy the discount code: `;
} else if (prerequisite_type === 'subtotal') {
text = `Purchase , and enjoy a discount when you buy an additional ${y}. Click to copy the discount code: `;
}
}
}
return `
`;
}()}
${text} ${discount_code}
Members only
${function(){
const {campaign} = data.pointsDeduction || {};
const {deduction_rate, max_deduction} = campaign || {};
const {points, order_amount} = deduction_rate || {};
const {member} = data.memberDetail || {};
const {active_point_amount = 0} = member || {};
const real_amount = active_point_amount / points * order_amount;
if(max_deduction) {
return `Your available points:
( = discount on your order. A maximum of can be deducted on each order)`;
}else{
if(active_point_amount > 0) {
return `Your available points:
( = discount on your order. You can deduct up to when you place your order immediately)`;
}else {
return ` Points can be offset against `;
}
}
}()}
Members only
${function(){
const {activity, discount_code} = data.coupon_recommendation || {};
const {discount_type, discount_value, prerequisite_value, prerequisite_type, obtain_product} = activity || {};
let text = '';
if(discount_type === 'percentage') {
if (prerequisite_type === 'none') {
text = `Order now to enjoy ${discount_value}% OFF. Click to copy the discount code: `;
}
if (prerequisite_type === 'quantity') {
text = `Get ${discount_value}% OFF your entire order when you purchase ${parseInt(prerequisite_value)} or more. Click to copy the discount code: `;
}
if (prerequisite_type === 'subtotal') {
text = `Spend to enjoy ${discount_value}% OFF on your entire order. Click to copy the discount code: `;
}
}else if(discount_type === 'fixed_amount') {
if (prerequisite_type === 'none') {
text = `Order now to get an instant discount of . Click to copy the discount code: `;
}
if (prerequisite_type === 'quantity') {
text = `Get an instant discount when you purchase ${parseInt(prerequisite_value)} items. Click to copy the discount code: `;
}
if (prerequisite_type === 'subtotal') {
text = `Spend to get an instant discount of . Click to copy the discount code: `;
}
} else if(discount_type === 'free_shipping') {
if (prerequisite_type === 'none') {
text = `Order now to enjoy free shipping. Click to copy the discount code: `;
}
if (prerequisite_type === 'quantity') {
text = `Free shipping on orders of ${parseInt(prerequisite_value)} items or more. Click to copy the discount code: `;
}
if (prerequisite_type === 'subtotal') {
text = `Spend to enjoy free shipping. Click to copy the discount code: `;
}
} else if(discount_type === 'buy_x_get_y') {
const x = prerequisite_value;
const y = obtain_product.product_count;
const obtain_value = obtain_product.obtain_value;
if(obtain_product.obtain_type === 'free') {
if (prerequisite_type === 'quantity') {
text = `Purchase the current product and enjoy a buy ${x} get ${y} Free offer. Click to copy the discount code: `;
} else if (prerequisite_type === 'subtotal') {
text = `Purchase the current product and enjoy a buy get ${y} Free offer. Click to copy the discount code: `;
}
}
if(obtain_product.obtain_type === 'percentage') {
if (prerequisite_type === 'quantity') {
text = `Purchase ${x} and enjoy an additional ${obtain_value}% OFF when you buy more than ${y}. Click to copy the discount code: `;
} else if (prerequisite_type === 'subtotal') {
text = `Purchase and enjoy an additional ${obtain_value}%% OFF when you buy more than ${y}. Click to copy the discount code: `;
}
}
if(obtain_product.obtain_type === 'fixed_amount') {
if (prerequisite_type === 'quantity') {
text = `Purchase ${x}, and enjoy a discount when you buy an additional ${y}. Click to copy the discount code: `;
} else if (prerequisite_type === 'subtotal') {
text = `Purchase , and enjoy a discount when you buy an additional ${y}. Click to copy the discount code: `;
}
}
}
return `
`;
}()}
${text} ${discount_code}
${function(){
const {campaign} = data.pointsDeduction || {};
const {deduction_rate, max_deduction} = campaign || {};
const {points, order_amount} = deduction_rate || {};
const {member} = data.memberDetail || {};
const {active_point_amount = 0} = member || {};
const real_amount = active_point_amount / points * order_amount;
if(max_deduction) {
return `Your available points:
( = discount on your order. A maximum of can be deducted on each order)`;
}else{
if(active_point_amount > 0) {
return `Your available points:
( = discount on your order. You can deduct up to when you place your order immediately)`;
}else {
return ` Points can be offset against `;
}
}
}()}
Members only
${function(){
const {discount_type, discount_value, prerequisite_value, prerequisite_type, obtain_product, max_free_shipping} = data.coupon_recommendation?.activity || {};
let value = '';
let unit = '';
if (discount_type === 'fixed_amount') {
value = ` `;
}
if (discount_type === 'percentage') {
value = `${parseInt(discount_value)}%`;
unit = `OFF`;
}
if (discount_type === 'free_shipping') {
if (max_free_shipping !== -1) {
value = `
FREE
SHIPPING
`;
unit = `Up to `;
} else {
value = `FREE`;
unit = `SHIPPING`;
}
}
if (discount_type === 'buy_x_get_y') {
const x = prerequisite_value;
const y = obtain_product.product_count;
const obtain_value = obtain_product.obtain_value;
if(obtain_product.obtain_type === 'free') {
value = `FREE`;
unit = `PRODUCT`;
}
if(obtain_product.obtain_type === 'percentage') {
value = `${obtain_value}%`;
unit = `OFF`;
}
if(obtain_product.obtain_type === 'fixed_amount') {
value = ` `;
}
}
return `
${value}
${unit}
`;
}()}
${function(){
const {discount_type, prerequisite_value, prerequisite_type, obtain_product} = data.coupon_recommendation?.activity || {};
if (discount_type !== 'buy_x_get_y') {
return `${data.coupon_recommendation?.campaign_name}`;
}
return '';
}()}
${function(){
const {discount_type, prerequisite_value, prerequisite_type, obtain_product} = data.coupon_recommendation?.activity || {};
if (discount_type === 'buy_x_get_y') {
const x = prerequisite_value;
const y = obtain_product.product_count;
const obtain_value = obtain_product.obtain_value;
if(obtain_product.obtain_type === 'free') {
if (prerequisite_type === 'quantity') {
return `Buy ${x} Get ${y} Free`;
} else if (prerequisite_type === 'subtotal') {
return `Buy Get ${y} Free`;
}
}
if(obtain_product.obtain_type === 'percentage') {
if (prerequisite_type === 'quantity') {
return `Buy ${x}, get ${y} at ${obtain_value}% OFF`;
} else if (prerequisite_type === 'subtotal') {
return `Buy , get ${y} at ${obtain_value}% OFF`;
}
}
if(obtain_product.obtain_type === 'fixed_amount') {
if (prerequisite_type === 'quantity') {
return `Buy ${x} get ${y} with off each`;
} else if (prerequisite_type === 'subtotal') {
return `Buy get ${y} with off each`;
}
}
}
return '';
}()}
redemption
Members only
Become a member
${function() {
const { benefits = [] } = data.memberDetail?.current_tier || {};
if(benefits.length === 0) {
return `
`;
}()}
With more ways to unlock exciting perks, this is your all access pass to exclusive rewards.
`
}
return `
${function(){
if (benefitItem.benefit_type === 'birthday') {
return `
`
}
if (benefitItem.benefit_type === 'point') {
return `
`
}
if (benefitItem.reward.discount_code_activity.discount_type === 'free_shipping') {
return `
`
}
if ((benefitItem.reward.discount_code_activity.discount_type === 'fixed_amount' || benefitItem.reward.discount_code_activity.obtain_product?.obtain_type === 'fixed_amount')) {
return `
`
}
if ((benefitItem.reward.discount_code_activity.discount_type === 'percentage' || benefitItem.reward.discount_code_activity.obtain_product?.obtain_type === 'percentage')) {
return `
`
}
if (benefitItem.reward.discount_code_activity.obtain_product?.obtain_type === 'free') {
return `
`
}
}()}
${benefitItem.name}
${benefitItem.desc}
Get discount code
${function(){
if (data.benefit_card_setting.display_discount_code && !data.pointsDeduction?.campaign?.campaign_id && !!data.coupon_recommendation?.activity && !!data.coupon_recommendation?.can_use) {
return `
`;
}
if (!!data.pointsDeduction?.campaign?.campaign_id && !!data.coupon_recommendation?.activity && !!data.coupon_recommendation?.can_use) {
return `
`;
}
if ((data.benefit_card_setting.display_points || data.benefit_card_setting.display_deduction) && !!data.pointsDeduction?.campaign?.campaign_id && (!data.coupon_recommendation?.activity || !data.coupon_recommendation?.can_use)) {
return `
`;
}
if (!data.pointsDeduction?.campaign?.campaign_id && !!data.coupon_recommendation?.activity && !data.coupon_recommendation?.can_use) {
return `
`;
}
return '';
}()}
${function(){
const {activity, discount_code} = data.coupon_recommendation || {};
const {discount_type, discount_value, prerequisite_value, prerequisite_type, obtain_product} = activity || {};
let text = '';
if(discount_type === 'percentage') {
if (prerequisite_type === 'none') {
text = `Order now to enjoy ${discount_value}% OFF. Click to copy the discount code: `;
}
if (prerequisite_type === 'quantity') {
text = `Get ${discount_value}% OFF your entire order when you purchase ${parseInt(prerequisite_value)} or more. Click to copy the discount code: `;
}
if (prerequisite_type === 'subtotal') {
text = `Spend to enjoy ${discount_value}% OFF on your entire order. Click to copy the discount code: `;
}
}else if(discount_type === 'fixed_amount') {
if (prerequisite_type === 'none') {
text = `Order now to get an instant discount of . Click to copy the discount code: `;
}
if (prerequisite_type === 'quantity') {
text = `Get an instant discount when you purchase ${parseInt(prerequisite_value)} items. Click to copy the discount code: `;
}
if (prerequisite_type === 'subtotal') {
text = `Spend to get an instant discount of . Click to copy the discount code: `;
}
} else if(discount_type === 'free_shipping') {
if (prerequisite_type === 'none') {
text = `Order now to enjoy free shipping. Click to copy the discount code: `;
}
if (prerequisite_type === 'quantity') {
text = `Free shipping on orders of ${parseInt(prerequisite_value)} items or more. Click to copy the discount code: `;
}
if (prerequisite_type === 'subtotal') {
text = `Spend to enjoy free shipping. Click to copy the discount code: `;
}
} else if(discount_type === 'buy_x_get_y') {
const x = prerequisite_value;
const y = obtain_product.product_count;
const obtain_value = obtain_product.obtain_value;
if(obtain_product.obtain_type === 'free') {
if (prerequisite_type === 'quantity') {
text = `Purchase the current product and enjoy a buy ${x} get ${y} Free offer. Click to copy the discount code: `;
} else if (prerequisite_type === 'subtotal') {
text = `Purchase the current product and enjoy a buy get ${y} Free offer. Click to copy the discount code: `;
}
}
if(obtain_product.obtain_type === 'percentage') {
if (prerequisite_type === 'quantity') {
text = `Purchase ${x} and enjoy an additional ${obtain_value}% OFF when you buy more than ${y}. Click to copy the discount code: `;
} else if (prerequisite_type === 'subtotal') {
text = `Purchase and enjoy an additional ${obtain_value}%% OFF when you buy more than ${y}. Click to copy the discount code: `;
}
}
if(obtain_product.obtain_type === 'fixed_amount') {
if (prerequisite_type === 'quantity') {
text = `Purchase ${x}, and enjoy a discount when you buy an additional ${y}. Click to copy the discount code: `;
} else if (prerequisite_type === 'subtotal') {
text = `Purchase , and enjoy a discount when you buy an additional ${y}. Click to copy the discount code: `;
}
}
}
return `
`;
}()}
${text} ${discount_code}
Members only
${function(){
const {campaign} = data.pointsDeduction || {};
const {deduction_rate, max_deduction} = campaign || {};
const {points, order_amount} = deduction_rate || {};
const {member} = data.memberDetail || {};
const {active_point_amount = 0} = member || {};
const real_amount = active_point_amount / points * order_amount;
if(max_deduction) {
return `Your available points:
( = discount on your order. A maximum of can be deducted on each order)`;
}else{
if(active_point_amount > 0) {
return `Your available points:
( = discount on your order. You can deduct up to when you place your order immediately)`;
}else {
return ` Points can be offset against `;
}
}
}()}
Members only
${function(){
const {activity, discount_code} = data.coupon_recommendation || {};
const {discount_type, discount_value, prerequisite_value, prerequisite_type, obtain_product} = activity || {};
let text = '';
if(discount_type === 'percentage') {
if (prerequisite_type === 'none') {
text = `Order now to enjoy ${discount_value}% OFF. Click to copy the discount code: `;
}
if (prerequisite_type === 'quantity') {
text = `Get ${discount_value}% OFF your entire order when you purchase ${parseInt(prerequisite_value)} or more. Click to copy the discount code: `;
}
if (prerequisite_type === 'subtotal') {
text = `Spend to enjoy ${discount_value}% OFF on your entire order. Click to copy the discount code: `;
}
}else if(discount_type === 'fixed_amount') {
if (prerequisite_type === 'none') {
text = `Order now to get an instant discount of . Click to copy the discount code: `;
}
if (prerequisite_type === 'quantity') {
text = `Get an instant discount when you purchase ${parseInt(prerequisite_value)} items. Click to copy the discount code: `;
}
if (prerequisite_type === 'subtotal') {
text = `Spend to get an instant discount of . Click to copy the discount code: `;
}
} else if(discount_type === 'free_shipping') {
if (prerequisite_type === 'none') {
text = `Order now to enjoy free shipping. Click to copy the discount code: `;
}
if (prerequisite_type === 'quantity') {
text = `Free shipping on orders of ${parseInt(prerequisite_value)} items or more. Click to copy the discount code: `;
}
if (prerequisite_type === 'subtotal') {
text = `Spend to enjoy free shipping. Click to copy the discount code: `;
}
} else if(discount_type === 'buy_x_get_y') {
const x = prerequisite_value;
const y = obtain_product.product_count;
const obtain_value = obtain_product.obtain_value;
if(obtain_product.obtain_type === 'free') {
if (prerequisite_type === 'quantity') {
text = `Purchase the current product and enjoy a buy ${x} get ${y} Free offer. Click to copy the discount code: `;
} else if (prerequisite_type === 'subtotal') {
text = `Purchase the current product and enjoy a buy get ${y} Free offer. Click to copy the discount code: `;
}
}
if(obtain_product.obtain_type === 'percentage') {
if (prerequisite_type === 'quantity') {
text = `Purchase ${x} and enjoy an additional ${obtain_value}% OFF when you buy more than ${y}. Click to copy the discount code: `;
} else if (prerequisite_type === 'subtotal') {
text = `Purchase and enjoy an additional ${obtain_value}%% OFF when you buy more than ${y}. Click to copy the discount code: `;
}
}
if(obtain_product.obtain_type === 'fixed_amount') {
if (prerequisite_type === 'quantity') {
text = `Purchase ${x}, and enjoy a discount when you buy an additional ${y}. Click to copy the discount code: `;
} else if (prerequisite_type === 'subtotal') {
text = `Purchase , and enjoy a discount when you buy an additional ${y}. Click to copy the discount code: `;
}
}
}
return `
`;
}()}
${text} ${discount_code}
${function(){
const {campaign} = data.pointsDeduction || {};
const {deduction_rate, max_deduction} = campaign || {};
const {points, order_amount} = deduction_rate || {};
const {member} = data.memberDetail || {};
const {active_point_amount = 0} = member || {};
const real_amount = active_point_amount / points * order_amount;
if(max_deduction) {
return `Your available points:
( = discount on your order. A maximum of can be deducted on each order)`;
}else{
if(active_point_amount > 0) {
return `Your available points:
( = discount on your order. You can deduct up to when you place your order immediately)`;
}else {
return ` Points can be offset against `;
}
}
}()}
Members only
${function(){
const {discount_type, discount_value, prerequisite_value, prerequisite_type, obtain_product, max_free_shipping} = data.coupon_recommendation?.activity || {};
let value = '';
let unit = '';
if (discount_type === 'fixed_amount') {
value = ` `;
}
if (discount_type === 'percentage') {
value = `${parseInt(discount_value)}%`;
unit = `OFF`;
}
if (discount_type === 'free_shipping') {
if (max_free_shipping !== -1) {
value = `
FREE
SHIPPING
`;
unit = `Up to `;
} else {
value = `FREE`;
unit = `SHIPPING`;
}
}
if (discount_type === 'buy_x_get_y') {
const x = prerequisite_value;
const y = obtain_product.product_count;
const obtain_value = obtain_product.obtain_value;
if(obtain_product.obtain_type === 'free') {
value = `FREE`;
unit = `PRODUCT`;
}
if(obtain_product.obtain_type === 'percentage') {
value = `${obtain_value}%`;
unit = `OFF`;
}
if(obtain_product.obtain_type === 'fixed_amount') {
value = ` `;
}
}
return `
${value}
${unit}
`;
}()}
${function(){
const {discount_type, prerequisite_value, prerequisite_type, obtain_product} = data.coupon_recommendation?.activity || {};
if (discount_type !== 'buy_x_get_y') {
return `${data.coupon_recommendation?.campaign_name}`;
}
return '';
}()}
${function(){
const {discount_type, prerequisite_value, prerequisite_type, obtain_product} = data.coupon_recommendation?.activity || {};
if (discount_type === 'buy_x_get_y') {
const x = prerequisite_value;
const y = obtain_product.product_count;
const obtain_value = obtain_product.obtain_value;
if(obtain_product.obtain_type === 'free') {
if (prerequisite_type === 'quantity') {
return `Buy ${x} Get ${y} Free`;
} else if (prerequisite_type === 'subtotal') {
return `Buy Get ${y} Free`;
}
}
if(obtain_product.obtain_type === 'percentage') {
if (prerequisite_type === 'quantity') {
return `Buy ${x}, get ${y} at ${obtain_value}% OFF`;
} else if (prerequisite_type === 'subtotal') {
return `Buy , get ${y} at ${obtain_value}% OFF`;
}
}
if(obtain_product.obtain_type === 'fixed_amount') {
if (prerequisite_type === 'quantity') {
return `Buy ${x} get ${y} with off each`;
} else if (prerequisite_type === 'subtotal') {
return `Buy get ${y} with off each`;
}
}
}
return '';
}()}
redemption
Members only
Get discount code
Congratulations! You have received a discount code
Enjoy discounts when paying for your order
${function(){
const {discount_type, discount_value, prerequisite_value, prerequisite_type, obtain_product, max_free_shipping} = data.coupon_recommendation?.activity || {};
let value = '';
let unit = '';
if (discount_type === 'fixed_amount') {
value = ` `;
}
if (discount_type === 'percentage') {
value = `${parseInt(discount_value)}%`;
unit = `OFF`;
}
if (discount_type === 'free_shipping') {
if (max_free_shipping !== -1) {
value = `
FREE
SHIPPING
`;
unit = `Up to `;
} else {
value = `FREE`;
unit = `SHIPPING`;
}
}
if (discount_type === 'buy_x_get_y') {
const x = prerequisite_value;
const y = obtain_product.product_count;
const obtain_value = obtain_product.obtain_value;
if(obtain_product.obtain_type === 'free') {
value = `FREE`;
unit = `PRODUCT`;
}
if(obtain_product.obtain_type === 'percentage') {
value = `${obtain_value}%`;
unit = `OFF`;
}
if(obtain_product.obtain_type === 'fixed_amount') {
value = ` `;
}
}
return `
${value}
${unit}
`;
}()}
${data.discount_code}
${function(){
switch(data.status || data) {
case 'COUPON_RECEIVE_INSUFFICIENT_POINTS_ERROR': return `
Insufficient
`;
case 'BIRTHDAY_NOT_COME': return `
Your birthday time has not yet come
`;
case 'SHOW_LOGIN_TIP':
case 'UNAUTHORIZED':
return `You have not yet joined as a member or logged into your account`;
case 'COUPON_RECEIVE_NOT_IN_TIME_ERROR':
case 'COUPON_NOT_FOUND_ERROR':
case 'CAMPAIGN_NOT_FOUND_ERROR': return `Points benefit does not exist. Please refresh the page`;
case 'COUPON_RECEIVE_NOT_ELIGIBLE_ERROR':
case 'COUPON_RECEIVE_UPPER_LIMIT_ERROR':
case 'COUPON_RECEIVE_FAILED_ERROR': return `redemption failed. Please refresh the page and try again.`;
case 'COUPON_RECEIVE_NO_STOCK_ERROR': return `The coupon has been redeemed!`;
case 'LOYALTY_SERVER_UNAUTHORIZED': return `Please log in to your account!`;
case 'LOYALTY_SERVER_CUSTOMER_NOT_FOUND_ERROR': return `User error detected. Please refresh the page and try again~`;
case 'INVALID_PHONE_NUMBER_ERROR': return `Please enter a valid phone`;
case 'BENEFIT_UNSUBSCRIBE_FAILED_ERROR': return `Network error. Please try again!`;
default: return `The network is abnormal or the system is busy, please refresh the page and try again~`;
}
}()}
Register
Please fill in the information below:
Already have an account?
Login
Register for more discounts