Your shopping bag is empty
Your cart is reserved for
!
-
*${item.quantity}
${item.item_text}
${discount_item.title}
(-)
${(function(){
var total_price = data.total_price;
var postageFreeAmount = 200;
var freeAmount = postageFreeAmount - total_price;
var isFreeShipping = freeAmount <= 0;
var rate = Math.min(total_price / postageFreeAmount * 100, 100).toFixed(2);
const textArray = ("Spend {{ amount }} more and get free shipping!").split(/\{\{\s*amount\s*\}\}/);
const textArrayHtml = textArray.map((text, index) => {
if (index == 0) {
return `${text}`;
}
return `${text}`;
}).join('');
return `
${textArrayHtml}
You've got free shipping
`
})()}
${ data.originData.message }
${function () {
if (!data.originData) return "";
let {
apply_scenario,
discount_info,
landing_page_info,
threshold_category
} = data.originData;
const progressDom = ``;
const { mobile_layout, show_add_to_cart, show_discount_label } = landing_page_info.product_display;
const isBXGY = discount_info.discount_type === "DT_CODE_BXGY";
const buyProductsDom = `
`;
const obtainProductsDom = `
`;
const is_obtain = threshold_category === 'THRESHOLD_CATEGORY_OBTAIN_PRODUCT' ? 'active' : '';
const tabsDom = `
${function(){
let liDom = '';
const items = [
{
text: landing_page_info.product.buy_product.text,
class: "",
value: 1
},
{
text: landing_page_info.product.obtain_product.text,
class: "cart-coupon-code-modal-tab__obtain",
value: 2,
is_obtain
}
];
for (item of items) {
liDom += `
- ${ item.text }
`
}
return liDom;
}()}
${buyProductsDom}
${obtainProductsDom}
`;
return `
${progressDom}
${isBXGY ? tabsDom : `
${buyProductsDom}
`}
`
}()}
const TAG = 'spz-custom-cart-coupon-code-utils';
class SpzCustomCartCouponCodeUtils extends SPZ.BaseElement {
constructor(element) {
super(element);
}
static deferredMount() {
return false;
}
isLayoutSupported(layout) {
return layout == SPZCore.Layout.LOGIC;
}
buildCallback() {
this.action_ = SPZServices.actionServiceForDoc(this.element);
this.keepOpenGuardBound_ = false;
this.registerAction('setSideBarHeight', this.setSideBarHeight_.bind(this));
this.onResize_ = this.setSideBarHeight_.bind(this);
window.addEventListener('resize', this.onResize_);
}
detachedCallback() {
if (this.onResize_) {
window.removeEventListener('resize', this.onResize_);
this.onResize_ = null;
}
}
ensureKeepOpenGuard_($sideBar) {
if (this.keepOpenGuardBound_) return;
this.keepOpenGuardBound_ = true;
const observer = new MutationObserver(() => {
if ($sideBar.hasAttribute('open') && $sideBar.hasAttribute('hidden')) {
$sideBar.removeAttribute('hidden');
this.setSideBarHeight_();
}
});
observer.observe($sideBar, { attributes: true, attributeFilter: ['hidden', 'open'] });
}
getOpenDrawer_() {
return document.querySelector('[data-section-type="cart_drawer"] spz-sidebar[open]');
}
setSideBarHeight_() {
const $sideBar = document.querySelector('#cart-coupon-code-modal');
if (!$sideBar) return;
this.ensureKeepOpenGuard_($sideBar);
const windowHeight = window.innerHeight;
const $drawer = this.getOpenDrawer_();
if (!$drawer) {
$sideBar.style.setProperty('max-height', windowHeight * 0.9 + 'px', 'important');
$sideBar.style.removeProperty('height');
$sideBar.style.removeProperty('width');
$sideBar.classList.remove('cart-coupon-code-modal--in-drawer');
return;
}
const drawerHeight = (windowHeight - 40) + 'px';
$sideBar.style.setProperty('max-height', drawerHeight, 'important');
$sideBar.style.setProperty('height', drawerHeight, 'important');
$sideBar.classList.add('cart-coupon-code-modal--in-drawer');
const rect = $drawer.getBoundingClientRect();
if (rect.width > 0) {
$sideBar.style.setProperty('width', rect.width + 'px', 'important');
}
}
}
SPZ.defineElement(TAG, SpzCustomCartCouponCodeUtils);
${function(){
const settings_product_image_hover_on = true;
const variantShowLimit = 4;
const private_id = 'product-tmpl-' + Math.random().toFixed(6).slice(-6);
const product_variants = data.variants || [];
const product_id = data.id;
const images = data.images || [];
const image = data.image || {};
const imageWidth = image.width;
let imageHeight = image.height;
const price = Number(data.price_min);
let compareAtPrice = Number(data.compare_at_price);
const type = data.type;
const isMock = data.isMock;
let product_image_hover_on = false;
for (item of product_variants) {
const vcap = Number(item.compare_at_price);
if (item.price == price && vcap > compareAtPrice) {
compareAtPrice = vcap;
}
}
let second_image = null;
if (settings_product_image_hover_on) {
for (img of images.slice(1)) {
if (img.src && img.src.indexOf('video=') === -1) {
second_image = img;
product_image_hover_on = true;
break;
}
}
}
const sold_label_on = !data.available;
let sale_label_on = false;
if (compareAtPrice > price && data.available) {
sale_label_on = true;
}
const diffPrice = compareAtPrice - price;
return `
${data.available ?
`
` : ''}
`;
}()}
const carousel = document.getElementById('marketing-quick-view-images');
const selector = document.getElementById('marketing-quick-view-thumb-images');
const resizeObserver = new ResizeObserver(entries => {
for (let entry of entries) {
const { height } = entry.contentRect;
selector.style.height = height + 'px';
}
});
resizeObserver.observe(carousel);
${function(){
const variantsNamesSet = new Set(data.options.map((opt) => opt.name.toLowerCase()) || []);
const handleName = (name) => name.replace(/\/|\\|\s|\'|\"|`|\<|\>/g, '');
const mouseoutevent = data.options.map((opt) => `@${handleName(opt.name)}Mouseout="qv-selected-render-${opt.id}.rerender(data=event,redo=true);"`).join(' ');
const mouseoverevent = data.options.map((opt) => `@${handleName(opt.name)}Mouseover="qv-selected-render-${opt.id}.rerender(data=event,redo=true);"`).join(' ');
const variants = data?.variants?.map((item) => item.image.path) || [];
const productData = data;
const images = data.images;
const selectedVariant = data.variants.find(v => v.available) || data.variants[0];
const selectedIndex = !!selectedVariant ? images.findIndex(img => img.src === (selectedVariant.image && selectedVariant.image.src)) : 0;
const initialSlide = selectedIndex === -1 ? 0 : selectedIndex;
return `
${images.map((image, index) => `
`).join('')}
${images.map(image => `
`).join('')}
${images.length > 1 ? `
` : ''}
`
}()}
${function(){
return (data.product.options || []).map((option, index) => {
const optionName = option.name || '';
const optionId = option.id || '';
return `
`
}).join('')
}()}
${function(){
const { currentOptName, originData: { selectData, value } } = data;
const optionValue = selectData ? selectData[currentOptName].value[0] : value;
return `${optionValue}`
}()}
${function(){
const productData = data.product;
const selectedVariant = productData.variants.find(v => v.available) || productData.variants[0];
const product_options = productData.options.filter(Boolean) || [];
const handleName = (name) => name.replace(/\/|\\|\s|\'|\"|`|\<|\>/g, '');
const mouseoutevent = productData.options.map((opt) => `@${handleName(opt.name)}Mouseout="qs-selected-render-${opt.id}.rerender(data=event,redo=true);"`).join(' ');
const mouseoverevent = productData.options.map((opt) => `@${handleName(opt.name)}Mouseover="qs-selected-render-${opt.id}.rerender(data=event,redo=true);"`).join(' ');
return `
` }()}
${function(){
return (data.product.options || []).map((option, index) => {
const optionName = option.name || '';
const optionId = option.id || '';
return `
`
}).join('')
}()}
${function(){
const { currentOptName, originData: { selectData, value } } = data;
const optionValue = selectData ? selectData[currentOptName].value[0] : value;
return `${optionValue}`
}()}
const TAG = 'spz-custom-marketing-utils';
class SpzCustomMarketingUtils extends SPZ.BaseElement {
constructor(element) {
super(element);
}
static deferredMount() {
return false;
}
isLayoutSupported(layout) {
return layout == SPZCore.Layout.LOGIC;
}
mountCallback() {
this.ensureToastInBody_('coupon-code-toast-wrap');
}
showCouponCodeToast_(message) {
this.ensureToastInBody_('coupon-code-toast-wrap');
const toastEl = document.getElementById('coupon-code-toast');
if (!toastEl) return;
SPZ.whenApiDefined(toastEl).then((apis) => {
apis.showToast(message);
});
}
ensureToastInBody_(id) {
const wrapEl = document.getElementById(id);
if (!wrapEl) return;
if (!wrapEl.closest('[data-section-type="cart_drawer"]')) return;
if (wrapEl.parentNode !== document.body) {
document.body.appendChild(wrapEl);
}
}
buildCallback() {
this.registerAction('addToCartTrigger', (invocation) => {
window.$ && $(document).trigger('dj.common.cart.change');
window.$ && $(document).trigger('dj.addToCart', invocation.event.detail);
});
this.registerAction('showAddToCartToast', () => {
this.showCouponCodeToast_("Added successfully");
});
}
}
SPZ.defineElement(TAG, SpzCustomMarketingUtils);
${function(){
if (data.status === 'APPLY_STATUS_SUCCESS' || !data.message) {
return ``
}
return `
${data.originData.message}
Add
`
}()}
${data.map( item => {
return `
`
}).join('')}
${data.map( item => {
return `
`
}).join('')}
${function(){
const code_data = data.originData.list;
if (!code_data || !code_data.length) return '';
const recommendDom = `
Recommend discount codes
`;
const discountCodeListDom = code_data.map( item => {
item.end_at = item.end_at == -1 ? item.end_at : item.end_at * 1000;
item.start_at *= 1000;
return `
`
}).join('');
return `
${discountCodeListDom}
`
}()}
${function() {
const textArray = ("Save {{save_amount}}").split(/\{\{\s*save_amount\}\}/);
if (textArray.length > 0 && textArray.length < 2) {
textArray.push('');
}
return textArray.map((text, index) => {
if (index == 0) {
return `${text}`;
}
return `
${text}
`;
}).join('');
}()}
${function() {
const textArray = ("Save {{save_amount}}").split(/\{\{\s*save_amount\}\}/);
if (textArray.length > 0 && textArray.length < 2) {
textArray.push('');
}
return textArray.map((text, index) => {
if (index == 0) {
return `${text}`;
}
return `
${text}
`;
}).join('');
}()}
-
${discount_application.title}:
-
${data.invalid_msg}
Taxes and shipping calculated at checkout