(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();
})();
Please refresh the page or try again later.
${function(){
const {discount_type, discount_value, prerequisite_value, prerequisite_type, obtain_product, max_free_shipping} = data.campaign?.reward.discount_code_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 = `
FREESHIPPING`;
} 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}
`;
}()}
Members only
${function(){
const {discount_type, prerequisite_value, prerequisite_type, obtain_product} = data.campaign?.reward.discount_code_activity || {};
if (discount_type !== 'buy_x_get_y') {
return `${data.campaign?.name}`;
}
return '';
}()}
${function(){
const {discount_type, prerequisite_value, prerequisite_type, obtain_product} = data.campaign?.reward.discount_code_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 '';
}()}
${data.discount_code}
${function(){
const { prerequisite_type, prerequisite_value, discount_type, obtain_product, max_free_shipping } = data.campaign?.reward.discount_code_activity || {};
if (prerequisite_type === 'none' && discount_type === 'free_shipping' && max_free_shipping !== -1) {
return `Up to , no threshold`;
}
if (prerequisite_type === 'quantity' && discount_type === 'free_shipping' && max_free_shipping !== -1) {
return `Up to , the order is available when it contains at least ${parseInt(prerequisite_value)} items`;
}
if (prerequisite_type === 'subtotal' && discount_type === 'free_shipping' && max_free_shipping !== -1) {
return `Up to , available when the order amount exceeds `;
}
if (prerequisite_type === 'none') {
return `No threshold`;
}
if (prerequisite_type === 'quantity') {
return `The order is available when it contains at least ${parseInt(prerequisite_value)} items`;
}
if (prerequisite_type === 'subtotal') {
return `Available when the order amount exceeds `;
}
if (discount_type === 'free_shipping' && max_free_shipping !== -1 ) {
return `Up to `
}
}()}
${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!`;
default: return `The network is abnormal or the system is busy, please refresh the page and try again~`;
}
}()}
${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 `