(function(){
let w = window.innerWidth;
function setHeaderCssVar() {
const headerEle = document.getElementById('shoplaza-section-header');
if(!headerEle){ return };
document.body.style.setProperty('--window-height', `${window.innerHeight}px`);
document.body.style.setProperty('--header-height', `${headerEle.clientHeight}px`);
const mdScorllHideEle = headerEle.querySelector('.header__mobile .header__scroll_hide');
if (mdScorllHideEle) {
document.body.style.setProperty('--header-scroll-hide-height-md', `${mdScorllHideEle.clientHeight}px`);
}
const pcScorllHideEle = headerEle.querySelector('.header__desktop .header__scroll_hide');
if (pcScorllHideEle) {
document.body.style.setProperty('--header-scroll-hide-height-pc', `${pcScorllHideEle.clientHeight}px`);
}
}
function handlResize() {
if(w == window.innerWidth){return};
w = window.innerWidth;
setHeaderCssVar();
};
function init(){
setHeaderCssVar();
window.removeEventListener('resize', window._theme_header_listener)
window._theme_header_listener = handlResize;
window.addEventListener('resize', window._theme_header_listener);
}
init();
})();
${function() {
const { status } = data;
if (status === 'UNAUTHORIZED') {
return `
`;
}
return '';
}()}
${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!`;
case 'INVITE_REFERRAL_COPY_TIP': return `Link copied`;
case 'CAMPAIGN_ALREADY_RECEIVED_ERROR': return `Received the activity`;
case 'CAMPAIGN_IS_EXPIRE_ERROR': return `Event has expired`;
case 'MEMBER_BIRTHDAY_ALREADY_EXIST_ERROR': return `Your birthday has already been set and cannot be changed.`;
case 'REDEEM_SUCCESS_AND_COPY_CODE': return `Redeemed & code copied`;
case 'CLAIM_SUCCESS': return `Claimed successfully`;
case 'JOIN_SUCCESS': return `Congratulations! You have successfully joined the membership!`;
case 'COPY_SUCCESS': return `Copied successfully`;
case 'BENEFIT_NOT_FOUND_ERROR': return `This benefit does not exist. Please refresh the page and try again.`;
default: return `The network is abnormal or the system is busy, please refresh the page and try again~`;
}
}()}
Members only
${function(){
if (data.has_received) {
return `Received `;
} else {
return `${data.campaign.name} Receive `;
}
}()}
${function(){
if (data.has_deduction_campaign) {
return `(Immediate Discount on Order Payment)`;
}
return ``;
}()}
${function(){
const { campaign } = data;
const includeType = ['include_collections', 'include_products'];
if (campaign.category === 'buy_x_get_y' || (campaign.event_type === 'successful_order' && (includeType.includes(campaign.campaign_rule.order_condition.applicable_type) || includeType.includes(campaign.campaign_rule.reward_rule.applicable_type)))) {
let tab_1_text = 'tab1';
let tab_2_text = 'tab2';
if (campaign.category === 'buy_x_get_y') {
const {discount_type, prerequisite_value, prerequisite_type, obtain_product} = campaign.reward.discount_code_activity || {};
const x = prerequisite_value;
const y = obtain_product.product_count;
const obtain_value = obtain_product.obtain_value;
if (prerequisite_type === 'quantity') {
tab_1_text = `Buy ${x} of these item(s)`;
} else if (prerequisite_type === 'subtotal') {
tab_1_text = `Buy of these item(s)`;
}
if(obtain_product.obtain_type === 'free') {
tab_2_text = `Free gift(s)`;
}
if(obtain_product.obtain_type === 'percentage') {
tab_2_text = `Offer item(s) at ${parseInt(obtain_value)}% off`;
}
if(obtain_product.obtain_type === 'fixed_amount') {
tab_2_text = `Offer item(s) with off`;
}
} else {
tab_2_text=`The order purchases the following items (rewarding points for each item)`;
if (campaign.campaign_rule.order_condition.min_order_paid > 0) {
tab_1_text = `The order must include any of the following items, and the order amount must exceed .`;
} else {
tab_1_text = `The order must contain any of the following items.`;
}
}
return `
${function(){
const order_id = data.data?.order_number || data.data?.order_id || '';
const platformMap = {
'facebook': 'Facebook',
'x': 'X (Twitter)',
'pinterest': 'Pinterest'
};
const share_platform = platformMap[data.data?.share_platform] || '';
const adjustMap = {
'expiry_compensation': `Points expiration compensation`,
'holiday_bonus': `Festival Rewards`,
'customer_complaint_compensation': `Customer complaint compensation`,
'custom': `${data.data?.reason?.note}`
}
const adjust_type = adjustMap[data.data?.reason?.type] || '';
switch(data.resource_type) {
case 'become_member': return `Bonus for joining the club.`;
case 'enter_phone_number': return `Bonus for completing mobile phone filling`;
case 'enter_birthday': return `Bonus for completing birthday filling`;
case 'successful_order': return `Bonus for completing payment of order ${order_id}`;
case 'order_returned': return `Deduction of for refund of order ${order_id} `;
case 'discount_code_received': return `Deduction of for redeeming ${data.data.campaign_name} benefit`;
case 'coupon_received': return `Deduction of for redeeming ${data.data.coupon_title} coupon`;
case 'expired': return `Expired`;
case 'upgrade_benefit': return `Bonus for member benefits`;
case 'periodic_benefit': return `Bonus for member benefits`;
case 'birthday_benefit': return `Bonus for birthday benefits`;
case 'import_member_points': return `Manual adjustment of points`;
case 'deduction': return `Redeem for off order ${order_id}`;
case 'deduction_returned': return `Refund for order ${order_id}`;
case 'member_migrate': return `System upgrade updates balance`;
case 'share_link': return `Share ${share_platform} reward `;
case 'benefit_package_issued': return `${data.data.name} Issue `;
case 'manual_adjust': return `${adjust_type}`;
case 'openapi_earn': return `${adjust_type}`;
case 'openapi_deduct': return `${adjust_type}`;
case 'compensation': return `Refund points for historical order consumption amount`;
case 'member_active_reward': return `Membership activation points`;
case 'gift_points': return `${data.data.campaign_name} Claim Points`;
case 'invite_referral': return `Referral reward`;
default: '';
}
}()}
${function(){
if (!data.is_show_expiration_time) return '';
const expiryText = data.expired_at
? `Expiry Date: `
: `Permanent Validity`;
return `|${expiryText}`;
}()}