SKU:650358
Good quality and low price
Your Best Choice
The current item does not participate in the discount gift campaign. Switch the participating items to check the design.
(This prompt will not be displayed on the client-side)
Free worldwide shipping over $49
Secure payments with Paypal
The current produc does not participate any Rebate. Switch the participating product to check the design.
(This prompt will not be displayed on the client-side.)
${function() {
const show = rebate.format_rules.length > data.maxShowCount;
return `
${rule}
${function() {
if(!show) return "";
return `
`;
}()}
`;
}()}
${originData.rebate.format_rules.join(", ")}
if(window.self === window.top) {
(window.disabled_exts ||=[]).push('product_detail_rebate');
}
class SpzRebateComponent extends SPZ.BaseElement {
constructor(element) {
super(element);
}
xhr_ = SPZServices.xhrFor(this.win);
viewport_ = this.getViewport();
action_ = null;
lang = document.documentElement.lang || 'en-US';
landPage = "\/promotions\/rebate\/";
pageType = 1;
cart = {"line_items":[{"id":"1683699297_9678787579053240df594cc44b6ec0a3","item_id":"1683699297","product_id":"1265f2cf-c121-422a-8ba0-6300f21ebca5","variant_id":"ab9a56f2-1d06-4ca9-9f60-1d3f0c0cc387","quantity":"1","properties":"","custom":false,"parts_price":null,"note":"","discount_applications":[{"type":"discount_rebate","subtype":"discount_rebate","discount_id":"656fd342-ee49-4434-aef7-c0e74bf23afe","title":"Threshold Promo","value":"","discount_type":"amount_percentage","value_type":"percentage","allocation_method":"across","target_selection":"all","target_type":"line_item","total_discount_amount":"10.58","discount_amount":"1","is_free_gift":false,"discount_quantity":1,"is_need_split":false,"discount_text":"Threshold Promo","groups":null,"extents":null,"icon":"\/\/img.fantaskycdn.com\/oss\/operation\/52a3d7f0a272be85092170dc93eefe81.svg"}],"variant_title":"","product_title":"Joy Sunday Owl 11CT Stamped Cross Stitch 24*28CM","product_handle":"embroidery-eco-cotton-thread-11ct-printed-owl-cross-stitch-kit-artwork-24x28cm-1140663","product_tags":["Cross stitch","Printing","Animal"],"published":true,"published_at":"2023-12-29T04:00:25Z","product_url":"\/products\/embroidery-eco-cotton-thread-11ct-printed-owl-cross-stitch-kit-artwork-24x28cm-1140663","inventory_quantity":200,"inventory_policy":"deny","inventory_tracking":true,"available":true,"available_quantity":200,"price":"4.99","compare_at_price":"0.00","cost_price":"8.40","weight":"0.09","weight_unit":"kg","sku":"1140663.01","spu":"1140663.01","vendor":"","vendor_url":"","taxable":true,"requires_shipping":true,"barcode":"","mixed_wholesale":false,"tax_code":"","retail_price":"0.00","product_type":"default","origin_price":"4.99","image":{"src":"\/\/img.fantaskycdn.com\/de23b199daeae89772730f80c5ed5851.jpeg","path":"de23b199daeae89772730f80c5ed5851.jpeg","width":1001,"height":1001,"alt":""},"options":[],"wholesale_price":[{"min_quantity":1,"price":"4.99"}],"line_price":"4.99","original_line_price":0,"saved_price":-4.99,"can_buy":true,"fixed_discount_total":"1.00","discount_total":"1.00","final_line_price":"3.99","final_price":"3.99"},{"id":"1683695839_9678787579053240df594cc44b6ec0a3","item_id":"1683695839","product_id":"320db3e6-113d-4523-aebd-7ad563388c3e","variant_id":"9b938668-5800-402f-9931-9f072450f102","quantity":"1","properties":"","custom":false,"parts_price":null,"note":"","discount_applications":[{"type":"discount_rebate","subtype":"discount_rebate","discount_id":"656fd342-ee49-4434-aef7-c0e74bf23afe","title":"Threshold Promo","value":"","discount_type":"amount_percentage","value_type":"percentage","allocation_method":"across","target_selection":"all","target_type":"line_item","total_discount_amount":"10.58","discount_amount":"1","is_free_gift":false,"discount_quantity":1,"is_need_split":false,"discount_text":"Threshold Promo","groups":null,"extents":null,"icon":"\/\/img.fantaskycdn.com\/oss\/operation\/52a3d7f0a272be85092170dc93eefe81.svg"}],"variant_title":"11CT - 32*28CM","product_title":"Joy Sunday Halloween Cabin 11CT\/14CT Stamped Cross Stitch 32*28CM","product_handle":"joy-sunday-halloween-cabin-11ct-14ct-stamped-cross-stitch-32-28cm","product_tags":["Cross stitch","Printing","Cartoon"],"published":true,"published_at":"2023-10-16T07:43:48Z","product_url":"\/products\/joy-sunday-halloween-cabin-11ct-14ct-stamped-cross-stitch-32-28cm","inventory_quantity":197,"inventory_policy":"deny","inventory_tracking":true,"available":true,"available_quantity":197,"price":"4.99","compare_at_price":"0.00","cost_price":"0.00","weight":"0.00","weight_unit":"kg","sku":"1066486","spu":"1066486","vendor":"","vendor_url":"","taxable":true,"requires_shipping":true,"barcode":"","mixed_wholesale":false,"tax_code":"","retail_price":"0.00","product_type":"default","origin_price":"4.99","image":{"src":"\/\/img.fantaskycdn.com\/58d9ecc06f24cf8302fdd934e9c22a3f.jpeg","path":"58d9ecc06f24cf8302fdd934e9c22a3f.jpeg","width":1001,"height":1001,"alt":""},"options":[{"name":"Style","value":"11CT - 32*28CM"}],"wholesale_price":[{"min_quantity":1,"price":"4.99"}],"line_price":"4.99","original_line_price":0,"saved_price":-4.99,"can_buy":true,"fixed_discount_total":"1.00","discount_total":"1.00","final_line_price":"3.99","final_price":"3.99"},{"id":"1683693317_9678787579053240df594cc44b6ec0a3","item_id":"1683693317","product_id":"8eaf8ce3-2a14-4d2a-9131-23de07980cd9","variant_id":"fb878826-b287-4af1-b475-83f30431b517","quantity":"1","properties":"","custom":false,"parts_price":null,"note":"","discount_applications":[{"type":"discount_rebate","subtype":"discount_rebate","discount_id":"656fd342-ee49-4434-aef7-c0e74bf23afe","title":"Threshold Promo","value":"","discount_type":"amount_percentage","value_type":"percentage","allocation_method":"across","target_selection":"all","target_type":"line_item","total_discount_amount":"10.58","discount_amount":"1.39","is_free_gift":false,"discount_quantity":1,"is_need_split":false,"discount_text":"Threshold Promo","groups":null,"extents":null,"icon":"\/\/img.fantaskycdn.com\/oss\/operation\/52a3d7f0a272be85092170dc93eefe81.svg"}],"variant_title":"Aegean Island, Thailand-11CT 20*49cm","product_title":"Joy Sunday Famous Scenery 11CT\/14CT Stamped Cross Stitch 16*38CM","product_handle":"joy-sunday-famous-scenery-14ct-stamped-cross-stitch-16-38cm","product_tags":["Cross stitch","Printing","Bundle sale","Bundle Sale"],"published":true,"published_at":"2024-11-04T07:41:17Z","product_url":"\/products\/joy-sunday-famous-scenery-14ct-stamped-cross-stitch-16-38cm","inventory_quantity":199,"inventory_policy":"deny","inventory_tracking":true,"available":true,"available_quantity":199,"price":"6.99","compare_at_price":"0.00","cost_price":"0.00","weight":"0.00","weight_unit":"kg","sku":"1470885.02","spu":"","vendor":"","vendor_url":"","taxable":true,"requires_shipping":true,"barcode":"","mixed_wholesale":false,"tax_code":"","retail_price":"0.00","product_type":"default","origin_price":"6.99","image":{"src":"\/\/img.fantaskycdn.com\/cf24e7f9f6ef810ca9de517d0dfc11c6.JPG","path":"cf24e7f9f6ef810ca9de517d0dfc11c6.JPG","width":800,"height":800,"alt":""},"options":[{"name":"Style","value":"Aegean Island, Thailand"},{"name":"CT","value":"11CT 20*49cm"}],"wholesale_price":[{"min_quantity":1,"price":"6.99"}],"line_price":"6.99","original_line_price":0,"saved_price":-6.99,"can_buy":true,"fixed_discount_total":"1.39","discount_total":"1.39","final_line_price":"5.60","final_price":"5.60"},{"id":"1683693155_9678787579053240df594cc44b6ec0a3","item_id":"1683693155","product_id":"8eaf8ce3-2a14-4d2a-9131-23de07980cd9","variant_id":"445575e0-0e17-41f5-8c2c-052258036029","quantity":"1","properties":"","custom":false,"parts_price":null,"note":"","discount_applications":[{"type":"discount_rebate","subtype":"discount_rebate","discount_id":"656fd342-ee49-4434-aef7-c0e74bf23afe","title":"Threshold Promo","value":"","discount_type":"amount_percentage","value_type":"percentage","allocation_method":"across","target_selection":"all","target_type":"line_item","total_discount_amount":"10.58","discount_amount":"1.4","is_free_gift":false,"discount_quantity":1,"is_need_split":false,"discount_text":"Threshold Promo","groups":null,"extents":null,"icon":"\/\/img.fantaskycdn.com\/oss\/operation\/52a3d7f0a272be85092170dc93eefe81.svg"}],"variant_title":"Niagara Falls-11CT 20*49cm","product_title":"Joy Sunday Famous Scenery 11CT\/14CT Stamped Cross Stitch 16*38CM","product_handle":"joy-sunday-famous-scenery-14ct-stamped-cross-stitch-16-38cm","product_tags":["Cross stitch","Printing","Bundle sale","Bundle Sale"],"published":true,"published_at":"2024-11-04T07:41:17Z","product_url":"\/products\/joy-sunday-famous-scenery-14ct-stamped-cross-stitch-16-38cm","inventory_quantity":199,"inventory_policy":"deny","inventory_tracking":true,"available":true,"available_quantity":199,"price":"6.99","compare_at_price":"0.00","cost_price":"0.00","weight":"0.00","weight_unit":"kg","sku":"1470885.01","spu":"","vendor":"","vendor_url":"","taxable":true,"requires_shipping":true,"barcode":"","mixed_wholesale":false,"tax_code":"","retail_price":"0.00","product_type":"default","origin_price":"6.99","image":{"src":"\/\/img.fantaskycdn.com\/67eaa447225dccb21260b904a548cc2e.JPG","path":"67eaa447225dccb21260b904a548cc2e.JPG","width":800,"height":800,"alt":""},"options":[{"name":"Style","value":"Niagara Falls"},{"name":"CT","value":"11CT 20*49cm"}],"wholesale_price":[{"min_quantity":1,"price":"6.99"}],"line_price":"6.99","original_line_price":0,"saved_price":-6.99,"can_buy":true,"fixed_discount_total":"1.40","discount_total":"1.40","final_line_price":"5.59","final_price":"5.59"},{"id":"1683691143_9678787579053240df594cc44b6ec0a3","item_id":"1683691143","product_id":"07863cd9-8c02-4303-8011-3e6c479b31f5","variant_id":"563cce01-098b-4142-b76c-ac57b0102ff3","quantity":"1","properties":"","custom":false,"parts_price":null,"note":"","discount_applications":[{"type":"discount_rebate","subtype":"discount_rebate","discount_id":"656fd342-ee49-4434-aef7-c0e74bf23afe","title":"Threshold Promo","value":"","discount_type":"amount_percentage","value_type":"percentage","allocation_method":"across","target_selection":"all","target_type":"line_item","total_discount_amount":"10.58","discount_amount":"2.4","is_free_gift":false,"discount_quantity":1,"is_need_split":false,"discount_text":"Threshold Promo","groups":null,"extents":null,"icon":"\/\/img.fantaskycdn.com\/oss\/operation\/52a3d7f0a272be85092170dc93eefe81.svg"}],"variant_title":"11CT 46*56CM","product_title":"Joy Sunday Happy Halloween 11CT\/14CT Stamped Cross Stitch 36*44CM","product_handle":"full-embroidery-eco-cotton-thread-14ct-printed-halloween-cross-stitch-kit-934460","product_tags":["Cross stitch","Printing","Festival"],"published":true,"published_at":"2023-04-17T07:23:39Z","product_url":"\/products\/full-embroidery-eco-cotton-thread-14ct-printed-halloween-cross-stitch-kit-934460","inventory_quantity":200,"inventory_policy":"deny","inventory_tracking":true,"available":true,"available_quantity":200,"price":"11.99","compare_at_price":"0.00","cost_price":"0.00","weight":"0.00","weight_unit":"kg","sku":"1428896","spu":"934460","vendor":"","vendor_url":"","taxable":true,"requires_shipping":true,"barcode":"","mixed_wholesale":false,"tax_code":"","retail_price":"0.00","product_type":"","origin_price":"11.99","image":{"src":"\/\/img.fantaskycdn.com\/a226c4568a7eb3e42fd62d85c889f125.jpeg","path":"a226c4568a7eb3e42fd62d85c889f125.jpeg","width":1001,"height":1001,"alt":""},"options":[{"name":"CT","value":"11CT 46*56CM"}],"wholesale_price":[{"min_quantity":1,"price":"11.99"}],"line_price":"11.99","original_line_price":0,"saved_price":-11.99,"can_buy":true,"fixed_discount_total":"2.40","discount_total":"2.40","final_line_price":"9.59","final_price":"9.59"},{"id":"1683688871_9678787579053240df594cc44b6ec0a3","item_id":"1683688871","product_id":"a4685dc4-d9e1-4a3c-a07e-11b475d9b945","variant_id":"8fb11fa3-ea81-481d-b2dd-a23482739b7d","quantity":"1","properties":"","custom":false,"parts_price":null,"note":"","discount_applications":[{"type":"discount_rebate","subtype":"discount_rebate","discount_id":"656fd342-ee49-4434-aef7-c0e74bf23afe","title":"Threshold Promo","value":"","discount_type":"amount_percentage","value_type":"percentage","allocation_method":"across","target_selection":"all","target_type":"line_item","total_discount_amount":"10.58","discount_amount":"3.39","is_free_gift":false,"discount_quantity":1,"is_need_split":false,"discount_text":"Threshold Promo","groups":null,"extents":null,"icon":"\/\/img.fantaskycdn.com\/oss\/operation\/52a3d7f0a272be85092170dc93eefe81.svg"}],"variant_title":"1Set(4PCS)-Stamped Cross Stitch-11CT(34*34CM)","product_title":"Joy Sunday Seasons 11CT\/14CT\/16CT Stamped\/ Counted Cross Stitch 26*26CM","product_handle":"joy-sunday-seasons-11ct-14ct-16ct-stamped-counted-cross-stitch-26-26cm","product_tags":["Cross stitch","Printing","Cartoon","Popular","Beginner","Bundle sale"],"published":true,"published_at":"2023-02-24T02:31:41Z","product_url":"\/products\/joy-sunday-seasons-11ct-14ct-16ct-stamped-counted-cross-stitch-26-26cm","inventory_quantity":88,"inventory_policy":"deny","inventory_tracking":true,"available":true,"available_quantity":88,"price":"16.96","compare_at_price":"19.96","cost_price":"0.00","weight":"0.00","weight_unit":"kg","sku":"BGC1046185","spu":"453397","vendor":"","vendor_url":"","taxable":true,"requires_shipping":true,"barcode":"","mixed_wholesale":false,"tax_code":"","retail_price":"0.00","product_type":"","origin_price":"16.96","image":{"src":"\/\/img.fantaskycdn.com\/3c091d50198b39d1913a3c7824796dd0.jpg","path":"3c091d50198b39d1913a3c7824796dd0.jpg","width":900,"height":900,"alt":""},"options":[{"name":"Style","value":"1Set(4PCS)"},{"name":"CANVAS","value":"Stamped Cross Stitch"},{"name":"CT","value":"11CT(34*34CM)"}],"wholesale_price":[{"min_quantity":1,"price":"16.96"}],"line_price":"16.96","original_line_price":19.96,"saved_price":3,"can_buy":true,"fixed_discount_total":"3.39","discount_total":"3.39","final_line_price":"13.57","final_price":"13.57"}],"ineffectives":[],"discount_applications":[{"type":"discount_rebate","subtype":"discount_rebate","title":"Threshold Promo","discount_amount":10.58,"message":"","discount_message":"","discount_id":"656fd342-ee49-4434-aef7-c0e74bf23afe","value_type":"percentage","target_type":"line_item","apply_method":"","target_selection":"all","discount_type":"discount_rebate","entitled_product_list":[],"properties":null,"discount_text":"Threshold Promo","is_free_gift":false,"extents":null,"icon":"\/\/img.fantaskycdn.com\/oss\/operation\/52a3d7f0a272be85092170dc93eefe81.svg"}],"invalid_msg":"","currency":"USD","note":"","created_at":"2025-03-27T00:52:51Z","updated_at":"2025-03-27T01:16:42Z","item_count":6,"original_line_price":"19.96","original_total_price":"19.96","line_price":"52.91","total_price":"42.33","total_discount":"10.58","total_weight":0.09,"discount_line_item_price":"10.58"};
initData = null;
rebateInfo = null;
renderData = null;
footerImage = `${this.win.SHOPLAZZA["image_domain"]}oss/operation/e8ebb03dbb710457ca3b4b6a70898ab2.svg`;
isLayoutSupported(layout) {
return layout == SPZCore.Layout.LOGIC;
}
buildCallback() {
this.initData = this.getProduct();
this.action_ = SPZServices.actionServiceForDoc(this.element);
this.registerAction("triggerGetRenderData", () => {
const event = SPZUtils.Event.create(this.win, "triggerGetRenderData", this.renderData);
this.action_.trigger(this.element, "getRenderData", event);
});
this.registerAction("bindPropagation", () => {
document.querySelector(".product_detail_rebate_list").addEventListener("click", e => {
e.stopPropagation();
this.win.sa &&
this.win.sa.track("plugin_rebate_promotion_click", {
plugin_timestamp: Date.now(),
plugin_location: "info",
product_id: this.initData.product.id,
discount_id: this.rebateInfo.discount_list.map((item) => item.discount_id)[0],
});
});
});
}
async mountCallback() {
document.addEventListener("dj.variantChange", e => {
const data = e.detail;
if (document.querySelector("#product-select-modal.show")) return;
if (this.initData && this.initData.product && data.product && this.initData.product.id === data.product.id) {
this.initData = data;
this.initRebate(this.initData, true);
} else {
this.initData = data;
this.getRebateInfo();
}
});
document.addEventListener("dj.addToCart", e => {
const v = e.detail;
this.rebateInfo &&
this.win.sa &&
this.win.sa.track("plugin_rebate_atc", {
variant_discount_id: this.getVariantDiscountId(v.variant_id).map(item => item.discount_id),
discount_ids: this.rebateInfo.discount_list.map(item => item.discount_id),
variant_id: v.variant_id,
product_id: v.product_id,
price: v.item_price,
number: v.number,
});
});
await this.getRebateInfo();
if (document.querySelector(".plugin-container__bottom-fixed")) {
this.showDiscountPopupsInfoBar();
} else {
this.win.addEventListener("extloaded", () => {
this.showDiscountPopupsInfoBar();
});
}
}
getProduct = (() => {
document.addEventListener("dj.variantChange", e => {
if (!e.detail || !e.detail.product) return;
const productJson = document.querySelector("#product-json");
if (productJson && productJson.textContent && JSON.parse(productJson.textContent)) {
productJson.textContent = JSON.stringify(e.detail);
}
if (this.win.jQuery && this.win.jQuery.fn && this.win.jQuery(document).data("djproduct")) {
this.win.jQuery(document).data("djproduct", e.detail);
}
});
return () => {
let productData = null;
if (this.win.jQuery && this.win.jQuery.fn) {
try {
let product = this.win.jQuery(document).data("djproduct");
if (product) {
productData = JSON.parse(JSON.stringify(product));
} else {
productData = null;
}
} catch (error) {
productData = null;
}
}
if (!productData) {
const productJson = document.querySelector("#product-json");
productData = (productJson && productJson.textContent && JSON.parse(productJson.textContent)) || null;
}
return productData;
};
})();
initRebate = this.win.SPZCore.Types.debounce(
this.win,
(async (data, variantChange) => {
let discount_list = Object.assign([], this.rebateInfo.discount_list);
/* 按子商品的多少对优惠信息进行排序 */
discount_list &&
discount_list.sort((a, b) => {
return b.variant_ids.length - a.variant_ids.length;
});
/* 选中子商品时 筛选子商品的优惠信息 */
if (data.selected && data.selected.id) {
discount_list = this.getVariantDiscountId(data.selected.id);
}
/* 无满减信息 */
if (!(discount_list && discount_list.length)) {
return;
}
const isSection = !!document.querySelector(
`div[data-section-type^="shoplazza://apps/publicapp/blocks/rebate"] #rebate_custom_component`
);
if (
(this.rebateInfo.rebate_type == "sku" && data && data.selected && data.selected.id) ||
this.rebateInfo.rebate_type == "spu"
) {
let nowLandpage = this.landPage;
if (discount_list[0]) {
nowLandpage = this.landPage + discount_list[0].discount_id || "";
}
const info = {
rebate: discount_list[0],
maxShowCount: this.win.innerWidth > 768 ? 3 : 1,
landPage: nowLandpage,
modalFooterImg: `url(${`${this.win.SHOPLAZZA["image_domain"]}oss/operation/e8ebb03dbb710457ca3b4b6a70898ab2.svg`})`,
};
this.renderData = info;
if(isSection) {
SPZ.whenApiDefined(
document.getElementById("app_rebate_section")
).then(apis => {
apis.render(info, true);
});
} else {
// 重新渲染 抖动问题处理
this.templates_ = SPZServices.templatesForDoc();
const newTplDom = await this.templates_.renderTemplate(document.querySelector('#appRebateBlockTpl'), info)
const parentDiv = document.querySelector('#app_rebate_block');
const oldDom = parentDiv.querySelector('.app_rebate_list');
if(oldDom){
parentDiv.replaceChild(newTplDom, oldDom);
} else {
parentDiv.appendChild(newTplDom);
}
}
}
this.insertSlideTag(this.rebateInfo.tag, variantChange);
var pluginCurrencyEvent = new CustomEvent("plugin_currency_update");
document.dispatchEvent(pluginCurrencyEvent);
}).bind(this),
10
);
getRebateInfo = async () => {
if (this.initData && this.initData.product && this.initData.product.id) {
var variant_ids = this.initData.product.variants.map(variant => variant.id);
const res = await this.xhr_.fetchJson(
"\/api\/discount-rebate\/product-discount",
{
method: "POST",
body: {
product_id: this.initData.product.id,
product_type: this.initData.product.product_type,
variant_ids: variant_ids,
},
}
);
if (!SPZCore.Types.isEmptyObject(res.rebate_info)) {
res.rebate_info.tag = res.tag;
res.rebate_info.rebate_type = res.rebate_type;
this.rebateInfo = res.rebate_info;
this.initRebate(this.initData);
} else {
if (this.win.top !== this.win.self) {
const noActivity = document.getElementById("no-rebate-activity");
noActivity && (noActivity["style"].display = "block");
}
}
}
};
getVariantDiscountId = (variant_id) => {
if (!variant_id || !this.rebateInfo) return [];
var rebateId = this.rebateInfo.variant_discount_map[variant_id];
return this.rebateInfo.discount_list.filter(item => item.discount_id == rebateId) || [];
};
insertSlideTag = (tag, variantChange) => {
setTimeout(() => {
if (tag) {
var tag_container;
var modal = document.getElementById("product-select-modal");
if (modal && modal.classList.contains("show")) {
if (!variantChange && modal.querySelector(".slider-discount-tag")) return;
if (
variantChange &&
modal.querySelector(".slider-discount-tag:not(.rebate-tag)")
)
return;
tag_container = modal;
} else {
var product_detail_card = document.querySelector(
'.page_container > [data-section-type="product_detail"], .page_container > [data-section-type="product-template"]'
);
if(!product_detail_card) return;
if (!variantChange && product_detail_card.querySelector(".slider-discount-tag")) return;
if (variantChange && product_detail_card.querySelector(".slider-discount-tag:not(.rebate-tag)"))
return;
tag_container = product_detail_card;
}
if (tag_container.matches("#product-select-modal") && this.pageType === 13 && document.documentElement.clientWidth < 768)
return;
const tagDom = `<div class="slider-discount-tag dj_skin_product_title rebate-tag">${tag}</div>`
if (document.querySelector(".sep-loaded-slider")) {
var loadedSlider = tag_container.querySelector(".sep-loaded-slider");
loadedSlider.querySelectorAll(".slider-discount-tag").forEach(function(element) {
element.remove();
});
loadedSlider.insertAdjacentHTML("beforeend", tagDom);
} else {
if (tag_container.querySelector(".support-slick")) {
var supportSlick = tag_container.querySelectorAll(".support-slick, .sep-slider");
supportSlick.forEach((element) => {
element.querySelectorAll(".slider-discount-tag").forEach((element) => {
element.remove();
});
element.insertAdjacentHTML("beforeend",tagDom);
});
} else {
var sepSlider = tag_container.querySelector(".sep-slider");
sepSlider.querySelectorAll(".slider-discount-tag").forEach(function(element) {
element.remove();
});
sepSlider.insertAdjacentHTML("beforeend",tagDom);
}
}
if (document.documentElement.clientWidth < 768) {
const sliderDiscountTagHeight = tag_container.querySelector(".slider-discount-tag").offsetHeight || 0;
document.querySelector(".product-image__swiper_bullets").style.bottom = `${sliderDiscountTagHeight + 15}px`;
}
}
}, 1000);
};
fetchInfoBar = () => {
let discount_ids = [];
if (this.pageType === 1) {
discount_ids = this.rebateInfo && this.rebateInfo.discount_list.map(item => item.discount_id);
} else if (this.pageType === 38) {
discount_ids = [this.win.rebateObj.rebateCollection_id] || [];
}
const productObj = this.getProduct();
return this.xhr_.fetchJson("\/api\/discount-rebate\/global-text", {
method: "POST",
body: {
product_type: productObj && productObj.product && productObj.product.product_type,
line_items: (this.cart.line_items || []).map(item => ({
variant_id: item.variant_id,
product_id: item.product_id,
quantity: item.quantity,
price: item.price,
selected: !item.unchecked,
})),
discount_ids: discount_ids,
},
});
};
renderBottomBanner = res => {
if (!res.tips) return;
if (document.querySelector(".discount__info-bar")) return;
var bar_style = `background:linear-gradient(90deg,${res.config.background_color_start},${res.config.background_color_end}); color:${res.config.color};`;
let data = { tips: res.tips, landPage: this.landPage + res.id, bar_style };
const html = SPZCore.Dom.htmlFor(this.element);
const banner = html([
`<a impr="1" imprevt="1" id="rebate_bottom_bar" href=${data.landPage} class="discount__info-bar text-truncate" data-activity-type="rebate" style="${data.bar_style}">${data.tips}</a>`,
]);
document.querySelector(".plugin-container__bottom-fixed").appendChild(banner);
const pluginCurrencyEvent = new CustomEvent("plugin_currency_update");
document.dispatchEvent(pluginCurrencyEvent);
if (res.id) {
var trackParams = {
page: this.pageType,
discount_id: res.id,
product_id: this.getProduct()?.product.id,
};
banner.addEventListener("click", () => {
this.win.sa &&
this.win.sa.track("plugin_rebate_promotion_click", {
plugin_timestamp: Date.now(),
plugin_location: "bottom_bar",
product_id: trackParams.product_id,
discount_id: trackParams.discount_id,
});
});
this.win.sa && this.win.sa.track("plugin_rebate_banner_pv", trackParams);
}
};
showDiscountPopupsInfoBar = () => {
if ([13, 14, 19, 30, 31].includes(this.pageType)) return;
if (document.querySelector(".plugin-container__bottom-fixed .discount__info-bar")) return;
this.fetchInfoBar().then(this.renderBottomBanner);
document.addEventListener("dj.cartChange", () => {
this.fetchInfoBar().then(this.renderBottomBanner);
});
};
}
SPZ.defineElement("spz-custom-rebate", SpzRebateComponent);