HOME
PRODUCT SOLUTIONS
CLIENT CASES
ABOUT US
${data.cart.item_count > 99 ? '99+' : data.cart.item_count}
let freeShippingRestTimer = null; async function showFreeShippingRest(e) { const freeShippingRest = document.querySelector('.layout-floating-cart__free-shipping--rest'); if (freeShippingRest) { if (freeShippingRestTimer) { clearTimeout(freeShippingRestTimer); } freeShippingRest.classList.add('flex'); freeShippingRestTimer = setTimeout(function() { freeShippingRest.classList.remove('flex'); freeShippingRestTimer = null; }, 6000); } } document.addEventListener('dj.cartItemChange', showFreeShippingRest); document.addEventListener('dj.cartItemDelete', showFreeShippingRest);
1/1
${data.index + 1}/${data.total}
1/1
${data.index + 1}/${data.total}
Home
Garden Fence
Facebook
Twitter
Pinterest
Facebook
Twitter
Pinterest
Cancel
Garden Fence
Garden Fence
₱1,223.00
₱1,547.00
${function() { const variantData = data.variant || {"id":"58db91e6-2c92-4406-aa6f-302a6849dc36","product_id":"a1f49b52-f1cb-48fa-b921-0646a2af79ad","title":"1500*2000","weight_unit":"kg","inventory_quantity":0,"sku":"","barcode":"","position":1,"option1":"1500*2000","option2":"","option3":"","note":"","image":null,"wholesale_price":[{"price":1547,"min_quantity":1}],"weight":"0","compare_at_price":"0","price":"1547","retail_price":"0","available":true,"url":"\/products\/garden-fence?variant=58db91e6-2c92-4406-aa6f-302a6849dc36","available_quantity":999999999,"options":[{"name":"Garden Fence","value":"1500*2000"}],"off_ratio":"0","flashsale_info":{"variant_id":"58db91e6-2c92-4406-aa6f-302a6849dc36","product_id":"","quantity":0,"discount_id":"","limit_time":0,"limit_buy":0,"user_limit_buy":0,"discount_sales":0,"discount_sales_rate":"","discount_stock":0,"ends_at":0,"starts_at":0,"allow_oversold":"","allocation_method":"","price":"1547","compare_at_price":"","discount_price":"1547","customary_saved_price":"","customary_off_ratio":"","discount_saved_price":"","discount_off_ratio":"0","use_before_price":false,"before_price":"","title":"","properties":"","color_setting_promotional_copy":"","discount_quantity":0,"is_need_split":false},"sales":0}; const saveType = null; const productSaveLabel = null; return `
-
${ variantData.off_ratio }%
`; }()}
${function() { const minInventory = parseInt('7'); const maxInventory = parseInt('10'); const randomInventory = Math.round(Math.random() * (maxInventory - minInventory)) + minInventory; const customText = "Only {stock} item(s) left in stock!".replace(/\{stock\}/g, '
' + randomInventory + '
'); const barWidth = (randomInventory / maxInventory) * 100 + '%'; return `
${customText}
`; }()}
people are viewing this right now
Garden Fence:
${data.value}
1500*2000
1500*1000
Please select a Garden Fence
${function(){ return `
Please select a Garden Fence
`; }()}
Quantity
Add to cart
Buy now
Product was out of stock.
Product is unavailable.
Add to cart
Buy now
${function(){ const dd = data.dd; const hh = data.hh; const mm = data.mm; const ss = data.ss; const sss = data.SSS; const hours = data.d * 24 + data.h; return `
${dd}D
·
${hours}
${hh}
:
${mm}
:
${ss}
.
${sss}
` }()}
class SpzCustomDiscountFlashsale extends SPZ.BaseElement { constructor(element) { super(element); this.xhr_ = SPZServices.xhrFor(this.win); this.getFlashSaleApi = "\/api\/storefront\/promotion\/flashsale\/display_setting\/product_setting"; this.timer = null; this.variantId = "58db91e6-2c92-4406-aa6f-302a6849dc36"; // 促销活动数据 this.flashsaleData = {} } isLayoutSupported(layout) { return layout == SPZCore.Layout.CONTAINER; } buildCallback() { this.templates_ = SPZServices.templatesForDoc(); this.viewport_ = this.getViewport(); // 挂载bind函数 解决this指向问题 this.render = this.render.bind(this); this.resize = this.resize.bind(this); this.switchVariant = this.switchVariant.bind(this); } mountCallback() { // 获取数据 this.getData(); this.element.onclick = (e) => { const cur = this.win.document.querySelector(".app_discount_flashsale_desc"); const setting = this.flashsaleData.product_setting; const landingUrl = `/promotions/discount-default/${this.flashsaleData.discount_info.id}`; const finalUrl = appDiscountUtils.resolveDiscountHref(setting, landingUrl); if (finalUrl && appDiscountUtils.inProductBody(this.element) && e.target !== cur) { this.win.open(finalUrl, '_blank', 'noopener'); } } // 绑定 this.viewport_.onResize(this.resize); // 监听子款式切换,重新渲染 this.win.document.addEventListener('dj.variantChange', this.switchVariant); } unmountCallback() { // 解绑 this.viewport_.removeResize(this.resize); this.win.document.removeEventListener('dj.variantChange', this.switchVariant); // 清除定时器 if (this.timer) { clearTimeout(this.timer); this.timer = null; } } resize() { if (this.timer) { clearTimeout(this.timer) this.timer = null; } this.timer = setTimeout(() => { this.render(); }, 200) } switchVariant(event) { const variant = event.detail.selected; if (variant.product_id == 'a1f49b52-f1cb-48fa-b921-0646a2af79ad' && variant.id != this.variantId) { this.variantId = variant.id; this.getData(); } } getData() { const reqBody = { product_id: "a1f49b52-f1cb-48fa-b921-0646a2af79ad", product_type: "default", variant_id: this.variantId } this.flashsaleData = {}; this.win.fetch(this.getFlashSaleApi, { method: "POST", body: JSON.stringify(reqBody), headers: { "Content-Type": "application/json" } }).then(async (response) => { if (response.ok) { this.flashsaleData = await response.json(); this.render(); } else { this.clearDom(); } }).catch(err => { this.clearDom(); }); } clearDom() { const children = this.element.querySelector('*:not(template)'); children && SPZCore.Dom.removeElement(children); } render() { this.templates_ .findAndRenderTemplate(this.element, { isMobile: appDiscountUtils.judgeMobile(), isRTL: appDiscountUtils.judgeRTL(), inProductDetail: appDiscountUtils.inProductBody(this.element), flashsaleData: this.flashsaleData, image_domain: this.win.SHOPLAZZA.image_domain, }) .then((el) => { this.clearDom(); this.element.appendChild(el); }) } } SPZ.defineElement('spz-custom-discount-flashsale', SpzCustomDiscountFlashsale);
You may also like
${function() { let list = data.length>20?data.slice(0,20):data; return `
` }()}
${Array(data?.images?.length > 5 ? 5 : data?.images?.length) .fill() .map((val, index) => index) .map((val) => `
`).join('')}
${Array(data.total || 0).fill().map((val, idx) => idx).map((val, idx) => `
`).join('')}
${Array(data.total || 0).fill().map((val, idx) => idx).map((val, idx) => `
`).join('')}
${data?.title || 'Product Title'}
From
Sold Out
Recently viewed
No products viewed
${function() { let list = data.length>20?data.slice(0,20):data; return `
` }()}
${Array(data?.images?.length > 5 ? 5 : data?.images?.length) .fill() .map((val, index) => index) .map((val) => `
`).join('')}
${Array(data.total || 0).fill().map((val, idx) => idx).map((val, idx) => `
`).join('')}
${Array(data.total || 0).fill().map((val, idx) => idx).map((val, idx) => `
`).join('')}
${data?.title || 'Product Title'}
From
Sold Out
1/
${data.index + 1}/${data.total}
${product.title}
-
${variant.off_ratio}%
-
See detail
Quantity
Product was out of stock.
Product is unavailable.
${selectedVariant.available ? "Add to cart" : "Sold out"}
Buy now
${option.name}:
${getSelectedOption(option.name).val[0]}
${data.value}
${value}
${value}
${option.name}
${value}
Please select a ${option.name}
${value}
Please select a ${option.name}
Please select a
Cart
(${data.data && data.data.count})
Your cart is empty
Shop now
Summary
Subtotal:
${discount_application.title}:
-
Total discount:
-
Total:
${data.invalid_msg}
Add order note
${data.note || data.value}
Check out
Taxes and shipping calculated at checkout
Payment method
You may also like
${option.name}
${value}
Sold out
Save ${ data.off_ratio }%
${data.title}
from
+${ data.thumbVariants.length - 5 }
+${ data.thumbVariants.length - 3 }
Please select a ${data.target_option.name}
${option.name}
${value}
Sold out
Save ${ data.off_ratio }%
${data.title}
from
+${ data.thumbVariants.length - 5 }
+${ data.thumbVariants.length - 3 }
Please select a ${data.target_option.name}
${data.invalid_msg}
Total:
Save
${data.total_discount}
${data.invalid_msg}
Check out
Taxes and shipping calculated at checkout
Summary
Subtotal:
${discount_application.title}:
-
Total discount:
-
Total:
${data.invalid_msg}
Check out
Taxes and shipping calculated at checkout
View cart
class SpzCustomFreeShippingRest extends SPZ.BaseElement { constructor(element) { super(element); this.freeShippingRestTimer = null; } isLayoutSupported(layout) { return layout == SPZCore.Layout.LOGIC; } buildCallback() { this.registerAction('showTips', () => { this.showTips_(); }); } showTips_(e) { const freeShippingRest = document.querySelector( '.layout-floating-cart__free-shipping--rest' ); if (freeShippingRest) { if (this.freeShippingRestTimer) { clearTimeout(this.freeShippingRestTimer); } freeShippingRest.classList.add('flex'); this.freeShippingRestTimer = setTimeout(function () { freeShippingRest.classList.remove('flex'); this.freeShippingRestTimer = null; }, 6000); } } } SPZ.defineElement('spz-custom-free-shipping-rest', SpzCustomFreeShippingRest);