class SpzCustomLabelScript extends SPZ.BaseElement { constructor(element) { super(element); } isLayoutSupported(layout) { return true; } mountCallback() { const script = this.element; const boxEl = script.closest('.product_snippet_label_area'); const labelEl = boxEl.querySelector('.product_snippet__label'); if(!labelEl) return; const observer = new ResizeObserver((entries) => { const labelEls = boxEl.querySelectorAll('.product_snippet__label'); const offsetWidth = Math.max(...Array.from(labelEls).map(el => el.offsetWidth)); if(offsetWidth>0){ const padding = offsetWidth / 2 + 8 + 'px'; boxEl.style.left = padding; boxEl.style.right = padding; boxEl.style.visibility = 'visible'; } }); observer.observe(labelEl); } } SPZ.defineElement('spz-custom-label-script', SpzCustomLabelScript); (function () { class SPZCustomEventTrack extends SPZ.BaseElement { constructor(element) { super(element); this.action_ = SPZServices.actionServiceForDoc(this.element); } isLayoutSupported(layout) { return true; } buildCallback() { this.setupAction_(); } track(key, value) { console.log('tracking...', key, value); if(window.sa){ window.sa.track(key, value); }else{ let sa = null; Object.defineProperty(window, 'sa',{ get: function() { return sa; }, set(val){ sa = val; sa.track(key, value); } }) } } setupAction_() { const clickParams = { business_type: 'product_theme', event_name: 'function_click', function_name: 'Farida', plugin_name: 'Farida', template_name: "product", template_type: 1, module: 'online_store', module_type: 'online_store', tab_name: '', card_name: '', event_developer: 'ccbGolumn', event_type: 'click', }; this.registerAction('trackClick', (e) => { const event_info = e.args || {}; this.track('function_click', { ...clickParams, event_info: JSON.stringify(event_info), }); }); this.registerAction('trackExpose', (e) => { const event_info = e.args || {}; this.track('function_expose', { ...clickParams, event_name: 'function_expose', event_type: 'expose', event_info: JSON.stringify(event_info), }); }); } } SPZ.defineElement('spz-custom-event-track', SPZCustomEventTrack); }())
(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(); })();

💕Valentine's Day Hot Sales 49% OFF💕Lazzda Electric Smooth Shaver - Awaken your confidence with every shave

🎁Achieve a smooth, close shave in seconds without painful cuts, bumps, or razor burn

$37.99
$70.89
-$32.90
Color:  Rose
Quantity
/** @private {string} */ class SpzCustomAnchorScroll extends SPZ.BaseElement { static deferredMount() { return false; } constructor(element) { super(element); /** @private {Element} */ this.scrollableContainer_ = null; } isLayoutSupported(layout) { return layout == SPZCore.Layout.LOGIC; } buildCallback() { this.viewport_ = this.getViewport(); this.initActions_(); } setTarget(containerId, targetId) { this.containerId = '#' + containerId; this.targetId = '#' + targetId; } scrollToTarget() { const container = document.querySelector(this.containerId); const target = container.querySelector(this.targetId); const {scrollTop} = container; const eleOffsetTop = this.getOffsetTop_(target, container); this.viewport_ .interpolateScrollIntoView_( container, scrollTop, scrollTop + eleOffsetTop ); } initActions_() { this.registerAction( 'scrollToTarget', (invocation) => this.scrollToTarget(invocation?.caller) ); this.registerAction( 'setTarget', (invocation) => this.setTarget(invocation?.args?.containerId, invocation?.args?.targetId) ); } /** * @param {Element} element * @param {Element} container * @return {number} * @private */ getOffsetTop_(element, container) { if (!element./*OK*/ getClientRects().length) { return 0; } const rect = element./*OK*/ getBoundingClientRect(); if (rect.width || rect.height) { return rect.top - container./*OK*/ getBoundingClientRect().top; } return rect.top; } } SPZ.defineElement('spz-custom-anchor-scroll', SpzCustomAnchorScroll); const STRENGTHEN_TRUST_URL = "/api/strengthen_trust/settings"; class SpzCustomStrengthenTrust extends SPZ.BaseElement { constructor(element) { super(element); this.renderElement_ = null; } isLayoutSupported(layout) { return layout == SPZCore.Layout.CONTAINER; } buildCallback() { this.xhr_ = SPZServices.xhrFor(this.win); const renderId = this.element.getAttribute('render-id'); SPZCore.Dom.waitForChild( document.body, () => !!document.getElementById(renderId), () => { this.renderElement_ = SPZCore.Dom.scopedQuerySelector( document.body, `#${renderId}` ); if (this.renderElement_) { this.render_(); } this.registerAction('track', (invocation) => { this.track_(invocation.args); }); } ); } render_() { this.fetchData_().then((data) => { if (!data) { return; } SPZ.whenApiDefined(this.renderElement_).then((apis) => { apis?.render(data); document.querySelector('#strengthen-trust-render-1539149753700').addEventListener('click',(event)=>{ if(event.target.nodeName == 'A'){ this.track_({type: 'trust_content_click'}); } }) }); }); } track_(data = {}) { const track = window.sa && window.sa.track; if (!track) { return; } track('trust_enhancement_event', data); } parseJSON_(string) { let result = {}; try { result = JSON.parse(string); } catch (e) {} return result; } fetchData_() { return this.xhr_ .fetchJson(STRENGTHEN_TRUST_URL) .then((responseData) => { if (!responseData || !responseData.data) { return null; } const data = responseData.data; const moduleSettings = (data.module_settings || []).reduce((result, moduleSetting) => { return result.concat(Object.assign(moduleSetting, { logos: (moduleSetting.logos || []).map((item) => { return moduleSetting.logos_type == 'custom' ? this.parseJSON_(item) : item; }) })); }, []); return Object.assign(data, { module_settings: moduleSettings, isEditor: window.self !== window.top, }); }); } } SPZ.defineElement('spz-custom-strengthen-trust', SpzCustomStrengthenTrust);

Shipping time & 30 days Money Back Guarantee

Shipping Policy
• Free shipping on orders $49+
• Please allow up to 1-3 business days for processing before your order ships.

Estimated Delivery Times
•Priority delivery: 5-7 business days to arrive.

• Standard delivery: 5-14 business days to arrive.
*Please note, estimated shipping times are not guaranteed.

Return Policy
Lazzda will accept exchanges & returns within 30 days of receiving.
• Clearance products, free gifts, bras & underwear are not eligible for return policy.
• Items must be unworn and unwashed items in their original condition and packaging. We simply ask that you try it on OVER panties or undergarments.
• In most cases, we can only process one return or exchange for each order. For your benefit, please carefully consider all the products you need to return.

Don't Miss Out on These Incredible Deals:

Buy 2 items: %5 off

Buy 3 items: %10 off

To take advantage of these amazing offers, just follow these steps:

ADD TO CART: Choose your favorite items from our collection and add at least 2 items to your cart for %5 off, add 3 items for %10 off, or add 3 items for % off %15.

Automatic discount: Discount will be automatically applied at checkout. No promo code required!

MIX AND MATCH: Feel free to mix and match styles, colors and sizes to suit your preferences. All styles from our collection included!

Due to high demand, stock is very limited, so act fast to get your favorite pieces at great prices. happy shopping!

Description

NEW: 🏆2024 RATED BEST WOMENS SHAVING PRODUCT

✅ Guaranteed! GoogleTrusted Store!
🛒 Payments Via PayPal® and CreditCard


No More Bumps, Irritation Or Cuts… Ever

Experience pain-free shaving with Lazzda, where comfort meets precision. Say goodbye to the dreaded post-shave bumps, irritation, and cuts forever. Our specially designed razors glide effortlessly across your skin, ensuring that each pass of the razor is smooth and gentle, leaving your skin not only hair-free but also remarkably soft and clear.

FEATURE:

Transform your skin with the Lazzda Smooth Shaver

Your skin has never been this smooth. The Lazzda Smooth Shaver glides effortlessly over your skin, eliminating nicks, cuts, and ingrown hairs. Say goodbye to painful irritation and hello to beautifully soft, flawless skin with our advanced, waterproof shaver.

All-Season Skin Perfection

Lazzda Smooth Shaver ensures flawless skin in any weather, any time of the year. Its advanced design offers smooth, painless shaving, keeping your skin soft and radiant whether it's summer or winter. Enjoy consistent, high-quality grooming regardless of the season.

Versatile capable of handling tough areas

Say goodbye to the hassle of multiple grooming tools and hello to the simplicity of our Lazzda 2-in-1 shaver, designed to meet all your grooming needs.

Why Lazzda Stands Out from the Competition

With these exceptional features, Lazzda Smooth Shaver sets a new standard in grooming, offering unmatched comfort, convenience, and quality that you won't find in other products on the market.

Get the facts with Dr Jian Sharma

"Shaving can cause skin irritation, ingrown hairs, and rashes due to the friction between the razor and the skin. This friction can lead to micro-abrasions, clogging hair follicles, and disrupting the skin barrier, resulting in discomfort and unsightly bumps. Using a high-quality, well-designed shaver like the Lazzda Smooth Shaver can minimize these issues, providing a smoother, irritation-free experience."     --Medical Advisor

How to use?

Specification

FAQS

Can I use this shaver anywhere on my body? 
Yes! The Lazzda Smooth Shaver is designed for versatile use and can safely be used on various parts of the body, including the face, legs, arms, underarms, and bikini area.
Is it suitable for sensitive skin? 
Absolutely! Lazzda Smooth Shaver features hypoallergenic blades designed to be gentle on sensitive skin, reducing the risk of irritation and providing a comfortable shave.
How do I clean the SnapAria Smooth Shaver? 
To clean Lazzda Smooth Shaver, detach the shaver head and rinse it under running water. Use the small brush included in the package to remove any remaining hair or residue. Ensure the shaver is turned off before cleaning.
Can I use it in the shower? 
Yes, Lazzda Smooth Shaver is 100% waterproof and can be safely used on wet skin. It performs well in both dry and wet conditions, so you can use it in the shower without any worries.
How often should I replace the shaver head? 
For the best performance and hygiene, it is recommended to replace the shaver head every 12 to 18 months. Regular replacements help maintain the sharpness of the blades and the effectiveness of your shave.

Click On "ADD TO CART" To Get Yours Now!

WHY US?👇

  • We work directly with manufacturers all over the world to ensure the best quality of our products. We have a Quality Control department which helps us to keep our promise!
  • Price is always competitive.
  • Awesome Customer Service
  • Amazing products along with High Quality

✈ Worldwide Shipping ✈  
🔒 100% Risk-Free Purchase 🔥 

  • We truly offer stunning, trendy high-quality products in the world.
  • We will do WHATEVER it takes with outstanding customer service support to assist everyone.
  • If you are not satisfied with receiving the goods, you can apply for a refund.
  • You can pay with PayPal, which will protect your money.

class SpzSmartBlockComponent extends SPZ.BaseElement { constructor(element) { super(element); this.templates_ = null; this.container_ = null; this.i18n_ = {}; this.config_ = {}; this.show_type_ = 3; this.product_resource_id_ = ''; this.collection_resource_id_ = ''; this.cart_items_ = []; this.customer_id_ = ''; this.order_id_ = ''; } static deferredMount() { return false; } isLayoutSupported(layout) { return layout == SPZCore.Layout.CONTAINER; } buildCallback() { const template_type = window.SHOPLAZZA.meta.page.template_type; if (template_type === 1) { this.show_type_ = 3; this.product_resource_id_ = window.SHOPLAZZA.meta.page.resource_id; } else if (template_type === 2) { this.show_type_ = 4; this.collection_resource_id_ = window.SHOPLAZZA.meta.page.resource_id; } else if (template_type === 15){ this.show_type_ = 5; } else if (template_type === 13){ this.show_type_ = 6; } else if (template_type === 20){ this.show_type_ = 7; this.customer_id_ = window.SHOPLAZZA.customer.customer_id; } else if (template_type === 35){ this.show_type_ = 8; this.order_id_ = window.location.pathname.split('/').pop(); } this.templates_ = SPZServices.templatesForDoc(this.element); this.setAction_(); } mountCallback() { console.log('appzebu smart mounted'); const that = this; const themeName = window.SHOPLAZZA.theme.merchant_theme_name; const isGeek = /Geek/.test(themeName); this.fetchRules().then((res) => { if (res && res.rules && res.rules.length) { const blockEl = document.getElementById('smart_recommend_block'); SPZ.whenApiDefined(blockEl).then((api) => { api.render({data: res}, true).then(() => { if (isGeek && that.show_type_ === 6) { blockEl.querySelector('.plugin_container_wrpper').style.padding = '30px 0'; } const recommendStyle = document.createElement('style'); recommendStyle.innerHTML = ` .plugin__recommend_container,.app-recommend-card { display: none !important; } `; document.head.appendChild(recommendStyle); const fetchList = []; res.rules.forEach((rule) => { fetchList.push(this.fetchRuleProductList(rule.id)); }); const fetchAll = Promise.all(fetchList); fetchAll.then((p_res) => { res.rules.forEach((rule, index) => { rule.products = p_res[index] && p_res[index].products; const ruleEl = document.getElementById('smart_recommend_rule_' + rule.id); SPZ.whenApiDefined(ruleEl).then((api) => { api.render({data: rule}, true).then(() => { that.impressListen(`#smart_recommend_rule_ul_${rule.id}`, function(){ that.trackRuleImpress(rule); }); const btnElList = document.querySelectorAll(`#smart_recommend_rule_ul_${rule.id} button`); btnElList.forEach((btnEl) => { if (btnEl && rule.config && rule.config.quick_shop_button_bg_color && rule.config.quick_shop_button_text_color) { btnEl.style.backgroundColor = rule.config.quick_shop_button_bg_color; btnEl.style.color = rule.config.quick_shop_button_text_color; } }) }); }); }); }); }) }) } else { if (window.top !== window.self) { const template_type = window.SHOPLAZZA.meta.page.template_type; const holderEl = document.getElementById('smart_recommend_preview_no_data_placeholder'); SPZ.whenApiDefined(holderEl).then((api) => { api.render({data: { isCart: template_type === 13, isCollection: template_type === 2, isProduct: template_type === 1, isIndex: template_type === 15 }}, true); }); } } }); } setAction_() { this.registerAction('quickShop', (data) => { const that = this; const product_id = data.args.product_id; const productIndex = data.args.productIndex; const rule_id = data.args.rule_id; const ssp = data.args.ssp; const scm = data.args.scm; const cfb = data.args.cfb; const ifb = data.args.ifb; const modalRender = document.getElementById('smart_recommend_product_modal_render'); if (product_id) { this.fetchProductData(product_id).then((res) => { const product = res.products && res.products.length && res.products[0] || {}; product.cfb = cfb; product.ifb = ifb; SPZ.whenApiDefined(modalRender).then((api) => { api.render({product: product, productIndex: productIndex, rule_id: rule_id, ssp: ssp, scm: scm, show_type: that.show_type_}, true).then(() => { const modalEl = document.getElementById('smart_recommend_product_modal'); SPZ.whenApiDefined(modalEl).then((modal) => { that.impressListen('#smart_recommend_product_modal', function(){ that.trackQuickShop({ rule_id: rule_id, product_id: product_id }); }); modal.open(); }); const formEl = document.getElementById('smart_recommend_product_form'); SPZ.whenApiDefined(formEl).then((form) => { form.setProduct(product); }); const variantEl = document.getElementById('smart_recommend_product_variants'); SPZ.whenApiDefined(variantEl).then((variant) => { variant.handleRender(product); }); }); }) }); } }); this.registerAction('handleScroll', (data) => { this.directTo(data.args.rule_id, data.args.direction); }); this.registerAction('handleProductChange', (data) => { const variant = data.args.data.variant; const product = data.args.data.product; const imageRenderEl = document.getElementById('smart_recommend_product_image'); SPZ.whenApiDefined(imageRenderEl).then((api) => { api.render({ variant: variant, product: product }, true); }); }); this.registerAction('handleAtcSuccess', (detail) => { const data = detail.args; data.data.product = data.data.product || {}; data.data.variant = data.data.variant || {}; const product_id = data.data.product.id; const product_title = data.data.product.title; const variant_id = data.data.variant.id; const price = data.data.variant.price; const rule_id = data.rule_id; const aid = `smart_recommend.${this.show_type_}.${rule_id}`; const ifb = data.data.product.ifb; const cfb = data.data.product.cfb; const ssp = data.ssp; const scm = data.scm; const spm = `smart_recommend_${this.show_type_}.${data.spmIndex}`; const params = { id: product_id, product_id: product_id, number: 1, name: product_title, variant_id: variant_id, childrenId: variant_id, item_price: price, source: 'add_to_cart', _extra: { aid: aid, ifb: ifb, cfb: cfb, scm: scm, spm: `..${window.SHOPLAZZA.meta.page.template_name}.${spm}`, ssp: ssp, } }; this.tranckAddToCart(params); }); this.registerAction('addATCHook', (data) => { const params = data.args; const spm = `smart_recommend_${this.show_type_}.${params.spmIndex}`; this.myInterceptor_ = window.djInterceptors && window.djInterceptors.track.use({ event: 'dj.addToCart', params: { aid: `smart_recommend.${this.show_type_}.` + params.rule_id, ssp: params.ssp, scm: params.scm, cfb: params.cfb, spm: `..${window.SHOPLAZZA.meta.page.template_name}.${spm}`, }, once: true }); }); } tranckAddToCart(detail) { if (window.$) { window.$(document.body).trigger('dj.addToCart', detail); } } fetchRules() { const payload = { show_type: this.show_type_, }; let that = this; if (this.show_type_ === 6) { let line_items = []; return this.fetchCart().then((res) => { if (res && res.cart && res.cart.line_items) { line_items = res.cart.line_items.map((item) => { return { product_id: item.product_id, variant_id: item.variant_id, quantity: item.quantity, price: item.price } }); } payload.line_items = line_items; that.cart_items_ = line_items; return that.fetchRulesRequest(payload); }); } else { if (this.show_type_ === 3) { payload.line_items = [{ product_id: this.product_resource_id_ }]; } else if (this.show_type_ === 4) { payload.collection_id = this.collection_resource_id_; } else if (this.show_type_ === 7) { payload.customer_id = this.customer_id_; } else if (this.show_type_ === 8) { payload.order_id = this.order_id_; } return this.fetchRulesRequest(payload); } } fetchRulesRequest(payload) { return fetch(window.SHOPLAZZA.routes.root + "/api/possum/recommend_query", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload) }).then(function(res){ if(res.ok){ return res.json(); } }); } fetchCart() { return fetch(`/api/cart/cart-select?r=${Math.random().toString(36).slice(-4)}`) .then((res) => { if (res.ok) { return res.json(); } }); } fetchRuleProductList(rule_id) { const payload = { page: 1, limit: 100, fields: ["title", "url", "image", "min_price_variant.price", "min_price_variant.compare_at_price"], rule_id: rule_id, }; if (this.show_type_ === 3) { payload.line_items = [{ product_id: this.product_resource_id_ }]; } else if (this.show_type_ === 4) { payload.collection_id = this.collection_resource_id_; } else if (this.show_type_ === 6) { payload.line_items = this.cart_items_; } else if (this.show_type_ === 7) { payload.customer_id = this.customer_id_; } else if (this.show_type_ === 8) { payload.order_id = this.order_id_; } return fetch(window.SHOPLAZZA.routes.root + "/api/possum/recommend_products", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload) }).then(function(res){ if(res.ok){ return res.json(); } }).catch(function(err){ console.log(err); }); } fetchProductData(product_id) { return fetch(window.SHOPLAZZA.routes.root + "/api/possum/products", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ product_ids: [product_id], fields: [ "images", "options", "min_price_variant", "variants"] }) }).then(function(res){ if(res.ok){ return res.json(); } }).catch(function(err){ console.log(err); const loadingEl = document.getElementById('smart_recommend_loading'); if (loadingEl) { loadingEl.style.display = 'none'; } }); } getStyle(ele, style) { if (!ele) return; if (window.getComputedStyle) { return window.getComputedStyle(ele)[style]; } return ele.currentStyle[style]; } directTo(id, direction) { const scrollElement = document.getElementById(`smart_recommend_rule_ul_${id}`); const blockWidth = parseInt(this.getStyle(scrollElement, 'width')); const scrollLength = (blockWidth * 0.19 - 12) * 5; const scrollPoint = scrollElement.scrollWidth - scrollElement.clientWidth; if (!scrollElement) return; if (direction === 'left') { if (document.dir === 'rtl') { scrollElement.scrollTo({ left: Math.abs(scrollElement.scrollLeft) >= scrollPoint - 100 ? 0 : scrollElement.scrollLeft - scrollLength, behavior: 'smooth' }); return; } scrollElement.scrollTo({ left: Math.max(scrollElement.scrollLeft - scrollLength, 0), behavior: 'smooth' }); } else { if (document.dir === 'rtl') { scrollElement.scrollTo({ left: Math.abs(scrollElement.scrollLeft) >= scrollPoint + 100 ? 0 : scrollElement.scrollLeft + scrollLength, behavior: 'smooth' }); return; } scrollElement.scrollTo({ left: scrollElement.scrollLeft >= scrollPoint - 100 ? 0 : scrollElement.scrollLeft + scrollLength, behavior: 'smooth' }); } } trackRuleImpress(rule) { if (window.sa && window.sa.track) { window.sa.track("plugin_common", { plugin_name: "upsell", event_type: "impressions", rule_id: rule.id, ssp: rule.ssp, scm: rule.scm, show_type: this.show_type_, support_app_block: window.SHOPLAZZA.theme.support_app_block }); window.sa.track("module_impressions", { aid: `smart_recommend.${this.show_type_}.${rule.id}`, support_app_block: window.SHOPLAZZA.theme.support_app_block }); } } trackQuickShop(data) { window.sa && sa.track && sa.track("plugin_common", { plugin_name: "upsell", event_type: "quick_shop", rule_id: data.rule_id, product_id: data.product_id, show_type: this.show_type_, }); } impressListen(selector, cb) { const el = document.querySelector(selector); const onImpress = (e) => { if (e) { e.stopPropagation(); } cb(); }; if (el && !el.getAttribute('imprsd')) { el.addEventListener('impress', onImpress) } else if (el) { onImpress(); } } } SPZ.defineElement('spz-custom-smart-block', SpzSmartBlockComponent);
(function() { const STATUS = { LOADING: 'loading', FINISH: 'finish' }; const RESULT = { EMPTY: 'data-empty' }; class SPZCustomCartSku extends SPZ.BaseElement { renderData = []; /** * add to cart reselect item, and delete process: * 1. record reselect id before show reselect modal * 2. add to cart success, mark `needDeleteReselectRecord` to true * 3. close reselect modal / drawer * 4. spz-cart re-render, triggered mounted event * 5. call refresh */ // mark delete reselect id recordReselectId = null; // mark should delete reselect record after spz-cart mounted event needDeleteReselectRecord = false; refreshLock = false; addToCartSuccess = false; // cache paused refresh data refreshDataCache = []; // cache similar products data, for manual add to cart similarData = []; constructor(element) { super(element); this.xhr_ = SPZServices.xhrFor(this.win); this.action_ = SPZServices.actionServiceForDoc(this.element); } setupAction_() { this.registerAction('refresh', (invocation) => { const data = invocation && invocation.args && invocation.args.data || {}; this.refresh(data); }); this.registerAction('deleteReselect', SPZCore.Types.debounce( this.win, (invocation) => { this.deleteReselect(invocation?.args?.id); }, 200 )); this.registerAction('deleteInvalid', SPZCore.Types.debounce( this.win, (invocation) => { this.deleteInvalid(invocation?.args?.id); }, 200 )); this.registerAction('setReselectRecordId', (invocation) => { this.setReselectRecordId(invocation?.args?.id); }); this.registerAction('clearNeedReselectRecord', (invocation) => { this.clearNeedReselectRecord(); }); this.registerAction('registerDeleteReselectTask', (invocation) => { this.registerDeleteReselectTask(invocation?.args?.data); }); this.registerAction('lockRefresh', (invocation) => { this.lockRefresh(); }); this.registerAction('releaseRefreshLock', (invocation) => { this.releaseRefreshLock(); }); this.registerAction('manualAddToCart', (invocation) => { this.manualAddToCart(invocation?.args?.id); }); this.registerAction('syncSimilarData', (invocation) => { this.syncSimilarData(invocation?.args?.data); }); // DEBUG this.registerAction('log', (invocation) => { const data = invocation && invocation.args && invocation.args.data || {}; console.log('log', invocation); }); } buildCallback() { this.setupAction_(); } isLayoutSupported(layout) { return true; } /** * 数据去重 * @param {Array} data */ uniq_(data) { const result = []; for(let i = 0; i < data.length; i++) { if(!result.includes(data[i])) { result.push(data[i]); } } return result; } checkRefreshLock() { if (this.refreshLock) { return false; } return true; } setLoading(isLoading) { SPZCore.Dom.toggleAttribute(this.element, STATUS.LOADING, isLoading); SPZCore.Dom.toggleAttribute(this.element, STATUS.FINISH, !isLoading); } setDataResult(data) { const isDataEmpty = !data.reselectSkus.length && !data.invalidSkus.length && !data.line_items.length; SPZCore.Dom.toggleAttribute(this.element, RESULT.EMPTY, isDataEmpty); } // 存在多次请求顺序问题 async refresh(_data) { // 接口失败时返回数据不为对象 if (!(typeof _data === 'object' && _data.line_items && _data.line_items.length > 0)) { const newData = { line_items: [], reselectSkus: [], invalidSkus: [], displayInvalidSkus: [] }; this.trigger_('refreshError', newData); this.setLoading(false); return; } if (!this.checkRefreshLock()) { this.setRefreshCache(_data); return; } this.setLoading(true); let data = _data; if (this.needDeleteReselectRecord && this.recordReselectId) { let hasError = false; try { data = await this.deleteReselectRecordBeforeRefresh(_data); } catch (e) { hasError = true; console.error(e); const newData = { ...data, reselectSkus: [], invalidSkus: [], displayInvalidSkus: [] }; this.trigger_('refreshError', newData); this.setLoading(false); this.setDataResult(newData); return; } this.needDeleteReselectRecord = false; if (hasError) { return; } } // 获取失效商品 const invisibleItems = data.ineffectives; // 获取失效商品内仅售罄商品的sku const soldOutItems = invisibleItems.filter(item => item.reason === "line_item_sold_out"); // 通过失效 sku 获取 spu, 注意去重 const soldOutSpuIds = this.uniq_(soldOutItems.map(item => item.product_id)); const querySpuIds = soldOutSpuIds.map(spuId => `ids[]=${spuId}`).join('&'); if (!soldOutSpuIds.length) { const newData = { ...data, reselectSkus: [], invalidSkus: [], displayInvalidSkus: [] }; this.trigger_('refreshSuccess', newData); this.renderData = newData; this.setLoading(false); this.setDataResult(newData); return; } // 请求 spu 下其他 sku 库存 this.xhr_.fetchJson(`/api/product/list?limit=${soldOutSpuIds.length}&${querySpuIds}`) .then(res => { const reselectSkus = []; const invalidSkus = []; // spu 维度展示 const displayInvalidSkus = []; res.data.list.forEach(product => { // spu 匹配, 存在多 sku 情况 const soldOutSkus = soldOutItems.filter(item => item.product_id === product.id); if (!soldOutSkus.length) { return; } // 通过失效 sku 获取 spu 下其他 sku 库存, 存在其他可用库存时标记为 "Reselect" 按钮可用 //const allowReselect = product.variants // .filter(variant => variant.option1 === soldOutProduct.variant.option1 && variant.option2 === soldOutProduct.variant.option2 && variant.option3 === soldOutProduct.variant.option3) // .some(variant => variant.available); // 查询售罄 sku 对应商品是否可加购, 标记为 Reselect 可用项 if (product.available) { reselectSkus.push(...soldOutSkus); // 若商品不可用(全部 sku 售罄), 归纳到失效商品列表 } else { invalidSkus.push(...soldOutSkus); // spu 维度, 仅添加一项 sku displayInvalidSkus.push(soldOutSkus[0]); } }); const newData = { ...data, reselectSkus, invalidSkus, displayInvalidSkus }; this.trigger_('refreshSuccess', newData); this.renderData = newData; this.setLoading(false); this.setDataResult(newData); }) .catch(err => { this.setLoading(false); console.error(err); this.trigger_('refreshError', data); }).finally(() => { }); } async deleteReselect(id, ignoreEmit) { if (!id) { return; } const targetSku = this.renderData.reselectSkus.find(item => item.id === id); try { const res = await this.xhr_.fetchJson(`/api/cart/${targetSku.variant_id}`, { method: 'DELETE', body: { id: targetSku.id, product_id: targetSku.product_id, variant_id: targetSku.variant_id, } }); const newData = { ...this.renderData, reselectSkus: this.renderData.reselectSkus.filter(item => item.id !== id), }; this.renderData = newData; !ignoreEmit && this.trigger_('deleteSuccess', newData); } catch (err) { console.error(err); !ignoreEmit && this.trigger_('deleteError', err); } } deleteInvalid(id) { if (!id) { return; } const targetSku = this.renderData.invalidSkus.find(item => item.id === id); this.xhr_.fetchJson(`/api/cart/${targetSku.variant_id}`, { method: 'DELETE', body: { id: targetSku.id, product_id: targetSku.product_id, variant_id: targetSku.variant_id, } }) .then(res => { const newData = { ...this.renderData, invalidSkus: this.renderData.invalidSkus.filter(item => item.id !== id), displayInvalidSkus: this.renderData.displayInvalidSkus.filter(item => item.id !== id), }; this.trigger_('deleteSuccess', newData); this.renderData = newData; }) .catch(err => { console.error(err); this.trigger_('deleteError', err); }); } // record reselect sku id before show reselect modal setReselectRecordId(id) { if (!id) { return; } this.recordReselectId = id; } async deleteReselectRecordBeforeRefresh(data) { if (!this.recordReselectId) { return; } await this.deleteReselect(this.recordReselectId, true); return { ...data, ineffectives: data.ineffectives.filter(item => item.id !== this.recordReselectId) } } clearNeedReselectRecord() { this.needDeleteReselectRecord = false; } registerDeleteReselectTask(productData) { const targetSku = this.renderData.reselectSkus.find(item => item.id === this.recordReselectId); if (targetSku?.variant_id && productData?.variant.id) { if (targetSku.variant_id === productData?.variant.id) { this.needDeleteReselectRecord = false; return; } } this.needDeleteReselectRecord = true; } // pause cart refresh(trigger by similar products) lockRefresh() { if (this.refreshLock) { return; } this.refreshLock = true; } releaseRefreshLock() { if (!this.refreshLock) { return; } this.refreshLock = false; this.refreshWithCache(); } // direct add_to_cart(trigger by similar products) async manualAddToCart(id) { const target = this.similarData.find(item => item.id === id); this.lockRefresh(); try { const res = await this.xhr_.fetchJson(`/api/cart`, { method: 'POST', body: { note: '', product_id: target.id, quantity: '1', variant_id: target.variants[0].id, refer_info: { source: 'add_to_cart' } } }); const newCartItems = res.data.items; this.setRefreshCache(newCartItems, true); } catch (err) { console.error(err); } } syncSimilarData(data) { this.similarData = data.data; } setRefreshCache(data, patch) { if (patch) { this.refreshDataCache = { ...this.refreshDataCache, line_items: [...this.refreshDataCache.line_items, ...data] }; } else { this.refreshDataCache = data; } } refreshWithCache() { this.refresh(this.refreshDataCache); } mountCallback() { } unmountCallback() { } /** * trigger event * @param {Object} data */ trigger_(name, data) { const event = SPZUtils.Event.create(this.win, `spz-custom-cart-sku.${name}`, { data, }); this.action_.trigger(this.element, name, event); } } SPZ.defineElement('spz-custom-cart-sku', SPZCustomCartSku); }()) (function () { class SPZCustomCartTrack extends SPZ.BaseElement { constructor(element) { super(element); this.action_ = SPZServices.actionServiceForDoc(this.element); } isLayoutSupported(layout) { return true; } buildCallback() { this.setupAction_(); } hash(val) { const hashKey = Object.keys(val).sort((a, b) => a - b).reduce((acc, k) => { acc += `{'${k}':'${val[k]}'}`; return acc; }, ''); return hashKey; } trackExtra(key, value) { console.log('trackExtra...', key, value); if (!window.sa) { return; } const hashKey = this.hash(value); let hasExtraInfo = false; if (window.sa.eventInfo && window.sa.eventInfo[key] && window.sa.eventInfo[key].extra_properties) { hasExtraInfo = window.sa.eventInfo[key].extra_properties.some(p => { return hashKey === this.hash(p); }); } if (hasExtraInfo) { return; } window.sa && window.sa.registerExtraInfo(key, value); } delExtraTrack(key, value) { const hashKey = this.hash(value); if (window.sa.eventInfo && window.sa.eventInfo[key] && window.sa.eventInfo[key].extra_properties) { window.sa.eventInfo[key].extra_properties = window.sa.eventInfo[key].extra_properties.filter(p => hashKey !== this.hash(p)); } } track(key, value) { console.log('tracking...', key, value); window.sa && window.sa.track(key, value); } setupAction_() { this.registerAction('registerReselectAtc', () => { this.trackExtra('add_to_cart', { function_name: 'Farida', action_type: 'reselect' }); }); this.registerAction('clearReselectAtc', () => { this.delExtraTrack('add_to_cart', { function_name: 'Farida', action_type: 'reselect' }); }); this.registerAction('registerSimilarAtc', () => { this.trackExtra('add_to_cart', { function_name: 'Farida', action_type: 'similar_product' }); }); this.registerAction('clearSimilarAtc', () => { this.delExtraTrack('add_to_cart', { function_name: 'Farida', action_type: 'similar_product' }); }); const clickParams = { business_type: 'product_plugin', event_name: 'function_click', function_name: 'Farida', plugin_name: 'Farida', template_name: 'cart', template_type: '13', module: 'online_store', module_type: 'online_store', tab_name: '', card_name: '', event_developer: 'ccbken', event_type: 'click', }; this.registerAction('trackDelReselect', () => { this.track('function_click', { ...clickParams, event_info: JSON.stringify({ action_type: 'cart_delete', element_type: 'sku' }) }); }); this.registerAction('trackClickReselect', () => { this.track('function_click', { ...clickParams, event_info: JSON.stringify({ action_type: 'reselect', element_type: 'sku' }) }); }); this.registerAction('trackDelSimilar', () => { this.track('function_click', { ...clickParams, event_info: JSON.stringify({ action_type: 'cart_delete', element_type: 'spu' }) }); }); this.registerAction('trackClickSimilar', () => { this.track('function_click', { ...clickParams, event_info: JSON.stringify({ action_type: 'reselect', element_type: 'spu' }) }); }); this.registerAction('trackOpenSimilar', () => { this.track('function_expose', { ...clickParams, event_name: 'function_expose', event_type: 'expose', event_info: JSON.stringify({ popup_name: 'farida_product_popup' }) }); }); } } SPZ.defineElement('spz-custom-cart-track', SPZCustomCartTrack); }())