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: "page", template_type: 3, 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); }())

90 Days Free Exchange & Return.

90 Days Free Exchange & Return.

90 Days Price Guaranteed.

90 Days Price Guaranteed.

  • Log in
  • Create an account
  • WOMEN
    • SILK CLOTHING
      Silk Tops Silk Tanks & Camisoles Silk Blouses & Shirts Silk T-shirts Silk Dresses Silk Pants Silk Skirts Silk Outwears Plus Size
    • CASHMERE
      Cashmere Sweater Cashmere Hoodie Cashmere Cardigan Cashmere Coat Cashmere Pants Cashmere Dress Cashmere Thermal Underwear Cashmere Robe Cashmere Set Cashmere Beanie Cashmere Scarf Cashmere Accessories
    • WOOL
      Wool Tops Wool Cardigans Wool Coats Wool Bottoms
    • LINEN
      Linen Tops Linen Shirt & Blouse Linen T-shirts Linen Camisole & Tank Linen Dresses Linen Pants Linen Shorts Linen Skirt Linen Homewears Linen Outwear Two-Pieces Set
    • SILK LOUNGEWEAR & SLEEPWEAR
      Silk Pajamas Silk Nightgown Silk Robe & Robe Set Silk Camisole Set Silk Travel Set Embroidered & Personalized Plus Size Couple
    • SILK LINGERIE
      Silk Bra & Bralette Silk Panties Silk Bra & Panties Set Silk Socks Silk Camisole Silk Leggings Silk Thermal
    • SILK ACCESSORIES
      Silk Scarf Silk Scrunchie Silk Sleep Cap Silk Eye Mask Silk Face Covering Silk Must-Haves For Travel
    • FEATURED
      Plus Size Embroidered & Personalized Silk Velvet Down Jackets Classic Luxury Organic & Eco-Friendly
  • MEN
    • SILK CLOTHING
      Silk Shirts & T-shirts Silk Beachwear Silk Bottom For Men
    • CASHMERE
      Cashmere Sweater Cashmere Hoodie Cashmere Cardigan Cashmere Pants Cashmere Thermal Underwear
    • WOOL
      Wool Tops Wool Cardigan Wool Coats
    • LINEN
      Linen Tops Linen Shirts Linen T-shirts Linen Pants Linen Shorts Linen Blazers
    • SILK LOUNGEWEAR & SLEEPWEAR
      Silk Pajamas Silk Robe Silk Homewear Couple Embroidered & Personalized
    • SILK LINGERIE
      Silk T-shirts Silk Underwear & Boxers Silk Socks Silk Thermal
    • SILK ACCESSORIES
      Silk Ties Silk Must-Haves For Travel
    • FEATURED
      Embroidered & Personalized Cashmere Wool No-Iron
  • KID
    • SILK LOUNGEWEAR & SLEEPWEAR
      Baby Girl Boy
    • SILK APPAREL
      Baby Girl Boy
    • CASHMERE
    • LINEN COLLECTION
      Linen Tops Linen Dresses Linen Pants
    • SILK BEDDING
      Silk Quilt Silk Pillowcase Silk Blanket
  • BEDDING
    • SILK BED LINENS
      Silk Fitted Sheets Silk Flat Sheets Silk Duvet Covers
    • SILK BEDDING SET
      Silk Sheet Sets Silk Duvet Cover Sets
    • SILK PILLOWCASES
      Silk Must-Have Pillowcases Silk Solid Pillowcases Silk Printed Pillowcases Silk Kids Pillowcases Silk European Pillowcases Silk Shams
    • SILK BASICS
      Silk Pillow Silk Comforter
    • FEATURED
      Classic Organic & Eco-Friendly Luxury 19 Momme 22 Momme 25 Momme
    • RESOURCES
      Gifts Of Sleep Wellness Silk Sheets Guide Silk Comforter Guide Silk Pillowcase Guide Sleep Better Guide
  • FEATURED
    • New Arrival 2025
      New In | June New In | May New In | April New In | March New In | February New In | January
    • Best Seller
    • Outlets
    Save 39% Save 39%

    Silk Cashmere Sweater with Loose Lazy Style

    $122.32 $199.00
    +7
  • More links

  • Log in
  • Create an account

WOMEN
SILK CLOTHING
Silk Tops Silk Tanks & Camisoles Silk Blouses & Shirts Silk T-shirts Silk Dresses Silk Pants Silk Skirts Silk Outwears Plus Size
CASHMERE
Cashmere Sweater Cashmere Hoodie Cashmere Cardigan Cashmere Coat Cashmere Pants Cashmere Dress Cashmere Thermal Underwear Cashmere Robe Cashmere Set Cashmere Beanie Cashmere Scarf Cashmere Accessories
WOOL
Wool Tops Wool Cardigans Wool Coats Wool Bottoms
LINEN
Linen Tops Linen Shirt & Blouse Linen T-shirts Linen Camisole & Tank Linen Dresses Linen Pants Linen Shorts Linen Skirt Linen Homewears Linen Outwear Two-Pieces Set
SILK LOUNGEWEAR & SLEEPWEAR
Silk Pajamas Silk Nightgown Silk Robe & Robe Set Silk Camisole Set Silk Travel Set Embroidered & Personalized Plus Size Couple
SILK LINGERIE
Silk Bra & Bralette Silk Panties Silk Bra & Panties Set Silk Socks Silk Camisole Silk Leggings Silk Thermal
SILK ACCESSORIES
Silk Scarf Silk Scrunchie Silk Sleep Cap Silk Eye Mask Silk Face Covering Silk Must-Haves For Travel
FEATURED
Plus Size Embroidered & Personalized Silk Velvet Down Jackets Classic Luxury Organic & Eco-Friendly
MEN
SILK CLOTHING
Silk Shirts & T-shirts Silk Beachwear Silk Bottom For Men
CASHMERE
Cashmere Sweater Cashmere Hoodie Cashmere Cardigan Cashmere Pants Cashmere Thermal Underwear
WOOL
Wool Tops Wool Cardigan Wool Coats
LINEN
Linen Tops Linen Shirts Linen T-shirts Linen Pants Linen Shorts Linen Blazers
SILK LOUNGEWEAR & SLEEPWEAR
Silk Pajamas Silk Robe Silk Homewear Couple Embroidered & Personalized
SILK LINGERIE
Silk T-shirts Silk Underwear & Boxers Silk Socks Silk Thermal
SILK ACCESSORIES
Silk Ties Silk Must-Haves For Travel
FEATURED
Embroidered & Personalized Cashmere Wool No-Iron
KID
SILK LOUNGEWEAR & SLEEPWEAR
Baby Girl Boy
SILK APPAREL
Baby Girl Boy
CASHMERE
LINEN COLLECTION
Linen Tops Linen Dresses Linen Pants
SILK BEDDING
Silk Quilt Silk Pillowcase Silk Blanket
BEDDING
SILK BED LINENS
Silk Fitted Sheets Silk Flat Sheets Silk Duvet Covers
SILK BEDDING SET
Silk Sheet Sets Silk Duvet Cover Sets
SILK PILLOWCASES
Silk Must-Have Pillowcases Silk Solid Pillowcases Silk Printed Pillowcases Silk Kids Pillowcases Silk European Pillowcases Silk Shams
SILK BASICS
Silk Pillow Silk Comforter
FEATURED
Classic Organic & Eco-Friendly Luxury 19 Momme 22 Momme 25 Momme
RESOURCES
Gifts Of Sleep Wellness Silk Sheets Guide Silk Comforter Guide Silk Pillowcase Guide Sleep Better Guide
FEATURED
New Arrival 2025
New In | June New In | May New In | April New In | March New In | February New In | January
Best Seller
Outlets
Log in
(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(); })();
Silk Flat Sheet Silk Flat Sheet
Silk Flat Sheet
Silk Fitted Sheet
Silk Flat Sheet Silk Flat Sheet
Silk Flat Sheet
Silk Fitted Sheet

SILK SHEETS

19 Momme Silk Flat Sheets REAL SILK LIFE

19 Momme Silk Flat Sheets

from $250.00
+5

22 Momme Silk Flat Sheets

from $370.00
+5
Save 11% Save 11%

25 Momme Silk Flat Sheet

from $402.00 $454.00
+6

19 Momme Silk Fitted Sheet

from $250.00
+5

22 Momme Silk Fitted Sheet

from $346.00
+5
Save 8% Save 8%

25 Momme Silk Fitted Sheet

from $474.00 $514.00
+6

19 Momme Silk Duvet Cover for Comforter Duvet

from $514.00
+5

22 Momme Silk Duvet Cover for Comforter Duvet

from $634.00
+6
19 Momme Silk Flat Sheets REAL SILK LIFE

19 Momme Silk Flat Sheets

from $250.00
+5

22 Momme Silk Flat Sheets

from $370.00
+5
Save 11% Save 11%

25 Momme Silk Flat Sheet

from $402.00 $454.00
+6

19 Momme Silk Fitted Sheet

from $250.00
+5
View more
Silk Sheet Set
Silk Duvet Cover Set
Silk Sheet Set
Silk Duvet Cover Set

SILK BED SET

19 Momme Silk Sheet Set | 4pcs

from $658.00
+5

22 Momme Silk Sheet Set | 4pcs

from $862.00
+6
Save 13% Save 13%

25 Momme Silk Sheet Set | 4pcs

from $874.00 $1,006.00
+6

19 Momme Silk Duvet Cover Set | 4pcs

from $802.00
+5

22 Momme Silk Duvet Cover Set | 4pcs

from $1,006.00
+6
Save 11% Save 11%

25 Momme Silk Duvet Cover Set | 4pcs

from $1,150.00 $1,294.00
+6

19 Momme Double Color None Stitching Silk Bedding Set 4PCS

from $1,066.00

19 Momme High Quality Double Color Silk Bedding Set 4PCS

from $970.00

19 Momme Silk Sheet Set | 4pcs

from $658.00
+5

22 Momme Silk Sheet Set | 4pcs

from $862.00
+6
Save 13% Save 13%

25 Momme Silk Sheet Set | 4pcs

from $874.00 $1,006.00
+6

19 Momme Silk Duvet Cover Set | 4pcs

from $802.00
+5
View more

SILK COMFORTER AND PILLOW

Filled Silk Pillow With Cotton Shell

from $250.00

Cotton Covered Silk Comforter

from $250.00

Summer Silk Covered Silk Comforter

from $546.00

All Season Silk Covered Silk Comforter

from $634.00

Filled Silk Pillow With Silk Shell

from $286.00

Silk Comforter Cotton Cover Solid Style

from $382.00

Latex Pillow Silk Sri Lanka Natural Latex Style

$346.00

Silk Latex Pillow Anti-mite Neck Massage Style

$322.00

Filled Silk Pillow With Cotton Shell

from $250.00

Cotton Covered Silk Comforter

from $250.00

Summer Silk Covered Silk Comforter

from $546.00

All Season Silk Covered Silk Comforter

from $634.00
View more

SILK DUVET COVER

19 Momme Silk Duvet Cover for Comforter Duvet

from $514.00
+5

22 Momme Silk Duvet Cover for Comforter Duvet

from $634.00
+6
Save 19% Save 19%

25 Momme Silk Duvet Cover for Comforter Duvet

from $658.00 $814.00
+6

19 Momme Both Sides In Mulberry Silk Pillowcase

from $50.00
+5

22 Momme Both Sides In Mulberry Silk Pillowcase

from $58.00
+7
Save 15% Save 15%

25 Momme Both Sides In Mulberry Silk Pillowcase

from $66.00 $78.00
+6

19 Momme Oxford Envelope Silk Pillowcase

from $66.00
+5

22 Momme Oxford Envelope Silk Pillowcase

from $66.00
+6

19 Momme Silk Duvet Cover for Comforter Duvet

from $514.00
+5

22 Momme Silk Duvet Cover for Comforter Duvet

from $634.00
+6
Save 19% Save 19%

25 Momme Silk Duvet Cover for Comforter Duvet

from $658.00 $814.00
+6

19 Momme Both Sides In Mulberry Silk Pillowcase

from $50.00
+5
View more
Solid Silk Pillowcase
Printed Silk Pillowcase
Kids Silk Pillowcase
Solid Silk Pillowcase
Printed Silk Pillowcase
Kids Silk Pillowcase

SILK PILLOWCASE

19 Momme Both Sides In Mulberry Silk Pillowcase

from $50.00
+5

22 Momme Both Sides In Mulberry Silk Pillowcase

from $58.00
+7
Save 15% Save 15%

25 Momme Both Sides In Mulberry Silk Pillowcase

from $66.00 $78.00
+6

19 Momme Oxford Envelope Silk Pillowcase

from $66.00
+5

22 Momme Oxford Envelope Silk Pillowcase

from $66.00
+6
Save 13% Save 13%

25 Momme Oxford Envelope Silk Pillowcase

from $82.00 $94.00
+6

22 Momme Terse Double-Sided Silk Pillowcase

from $58.00
+5

19 Momme Terse Double-Sided Lacing Silk Pillowcase

$114.00

19 Momme Both Sides In Mulberry Silk Pillowcase

from $50.00
+5

22 Momme Both Sides In Mulberry Silk Pillowcase

from $58.00
+7
Save 15% Save 15%

25 Momme Both Sides In Mulberry Silk Pillowcase

from $66.00 $78.00
+6

19 Momme Oxford Envelope Silk Pillowcase

from $66.00
+5
View more

Worry - Free Return

Enjoy worry - free returns within 90 days of purchase. Shop Now, Easy Return Later !

Easy Price Guarantee

Enjoy a 90 - day price guarantee. Shop with confidence: easy price guarantee included.

Human Customer Service

Experience personalized human support now. At your service with sincerity.

Offers, new arrivals, restocks and more.
Please enter a valid email address.
Please enter your email address.
Thanks for subscribing

REAL SILK LIFE

  • About Us
  • Our Silk
  • Our Materials
  • Silk Care
  • Gifts Guide
  • Sustainability
  • Blog

REAL SILK LIFE

  • About Us
  • Our Silk
  • Our Materials
  • Silk Care
  • Gifts Guide
  • Sustainability
  • Blog

SUPPORT

  • Contact Us
  • Return & Exchange policy
  • Shipping Information
  • Payment Method

SUPPORT

  • Contact Us
  • Return & Exchange policy
  • Shipping Information
  • Payment Method

FEATURED

  • E-Gift Card
  • Gift Box
  • Monogrammed
  • New Arrival
  • Best Seller
  • Last Chance

FEATURED

  • E-Gift Card
  • Gift Box
  • Monogrammed
  • New Arrival
  • Best Seller
  • Last Chance

Follow us

Follow us

  • American Express
  • Mastercard
  • PayPal
  • Visa
  • Diners Club
  • Discover
  • Maestro
  • Apple Pay
  • Google Pay
© 2025 REAL SILK LIFE Terms Of Service Privacy Policy Intellectual Property Rights
(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' || !Array.isArray(_data.line_items))) { 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); }())

Back

You may also like

Back

View Cart