(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 `