${(function(){ const get_random_six_digits = () => { return Math.random().toString().slice(-6) }; const wholesale_enabled = false; const setting_product_image_display = "natural"; const product_image = data.image; const secondary_image = data.secondImage; const image_width = product_image.width; let image_height = product_image.height; if(setting_product_image_display == '100%'){ image_height = image_width }else if(setting_product_image_display == '133.33%'){ image_height = image_width * 1.3333; }; const product_image_hover_on = true && !!secondary_image.src; const has_save_label = false && ((+data.compare_at_price) > (+data.price)); const is_single_variant = data.variants.length == 1; const min_price_variant_href = (data.min_price_variant && data.min_price_variant.available) ? data.min_price_variant.withinUrl : data.withinUrl; const retail_price_max = data.retail_price_max || data.compare_at_price_max; const THUMBNAILS_MAX_SIZE = 3; const thumbnails = data.thumbVariants.slice(0, THUMBNAILS_MAX_SIZE); const image_wrap_id = 'image_wrap_' + get_random_six_digits(); const image_carousel_id = 'image_carousel_' + get_random_six_digits(); const thumbnails_selector_id = 'thumbnails_selector_' + get_random_six_digits(); const form_id = 'form_' + get_random_six_digits(); const mixed_wholesale = data.mixed_wholesale; return `
${ data.available ? `` : "Sold out" }
Mixed Lot
${data.title}
${ data.price_min != data.price_max ? `from
` : `
` }
` })()}
BUY 1 GET 2nd 20% OFF
BUY 2 GET 3rd 50% OFF
BUY 3 GET 4th 80% OFF ✨ BUY 4 GET 5th FREE
BUY 1 GET 2nd 20% OFF
BUY 2 GET 3rd 50% OFF
BUY 3 GET 4th 80% OFF ✨ BUY 4 GET 5th FREE
const marketSlot = document.querySelector(".plugin_c_market"); if(marketSlot) { marketSlot.remove(); }
const SITE = (window.C_SETTINGS || window[atob('U0hPUExBWlpB')])?.routes?.root || ''; const MARKET_THEME_SETTINGS = `${SITE}/api/markets/theme_setting`; const MARKET_COUNTRIES = `${SITE}/api/markets/countries`; const IP_MATCHING_MARKET = `${SITE}/api/front/station`; const MARKET_LANGUAGES = `${SITE}/api/markets/:id/active_languages`; const URL_REDIRECT = '_market_redirected'; const COOKIE_TIPS_NAME = 'market_no_tips'; const COOKIE_TIPS_EXPIRES = 1000 * 60 * 60 * 24 * 14; const MARKET_COUNTRY_COOKIE = '_shoplazza_market_country'; const MARKET_MODAL_LOADED = '__market_modal_loaded__'; const PROPERTY_SELECTED = 'selected'; const MARKET_PC_HEADER_TRIGGER = 'market-pc-header-trigger'; const MARKET_PC_HEADER_COUNTRY_SELECT_TITLE = 'market-pc-header-country-select-title'; const MARKET_PC_HEADER_LANGUAGE_SELECT_TITLE = 'market-pc-header-language-select-title'; const MARKET_PC_HEADER_LANGUAGE_SELECT_SUB_TITLE = 'market-pc-header-language-select-sub-title'; const MARKET_PC_HEADER_COUNTRY_SELECT_SUB_TITLE = 'market-pc-header-country-select-sub-title'; const MARKET_FLAG = 'market-flag'; const MARKET_SELECT_VALUE = 'market-select-value'; const MARKET_CURRENCY = 'market-currency'; const MARKET_CURRENCY_SYMBOL = 'market-currency-symbol'; const MARKET_SELECT_ITEM = 'market-select-item'; const MARKET_SELECT_ITEM_ID = 'market-select-item-id'; const MARKET_SELECT_LIST = 'market-select-list'; const MARKET_LANGUAGE_SELECT = 'market-language-select'; const MARKET_COUNTRY_SELECT = 'market-country-select'; const MARKET_MODAL = 'market-modal'; const MARKET_GATEWAY_REDIRECT_MODAL = 'market-gateway-redirect-modal'; const MARKET_RESELECT_MODAL = 'market-reselect-modal'; const MARKET_MODAL_FLAG = 'market-modal-flag'; const MARKET_MODAL_COUNTRY_CODE = 'market-modal-country-code'; const MARKET_MODAL_CURRENCY_SYMBOL = 'market-modal-currency-symbol'; const MARKET_MODAL_CLOSE = 'market-modal-close'; const MARKET_MODAL_CONFIRM = 'market-modal-confirm'; const MARKET_MODAL_RESELECT = 'market-modal-reselect'; const MARKET_MODAL_RESELECT_COUNTRY_SELECT = 'market-modal-reselect-country-select'; const DATA_SECTION_TYPE = 'data-section-type'; const SECTION_TYPE_HEADER = 'header'; const SECTION_TYPE_FOOTER = 'footer'; class SpzCustomMarket extends SPZ.BaseElement { constructor(element) { super(element); this.global = null; this.useCountrySelect_ = false; this.useLanguageSelect_ = false; this.useModal_ = false; this.isSingleSelectMode_ = false; this.blockSectionPosition_ = ''; this.isEditMode = false; this.ipMatchingMarket = null; this.marketCountryList = []; this.marketLanguages = []; this.toast = null; } static deferredMount() { return false; } isLayoutSupported(layout) { return layout == SPZCore.Layout.LOGIC; } buildCallback() { console.debug('Geolocation'); this.xhr_ = SPZServices.xhrFor(this.win); const platform = SPZServices.platformFor(this.win); this.isIOS_ = platform.isIos(); this.action_ = SPZServices.actionServiceForDoc(this.element); this.global = this.win.C_SETTINGS || this.win[atob('U0hPUExBWlpB')]; this.isEditMode = new URLSearchParams(this.win.location.search).get('preview_theme_id') && new URLSearchParams(this.win.location.search).get('oseid'); this.init_(); } showToast_(content) { if (!this.toast) { this.toast = self.document.createElement('ljs-toast'); this.toast.setAttribute('layout', 'nodisplay'); this.toast.setAttribute('hidden', ''); this.toast.setAttribute('duration', '2000'); this.element.appendChild(this.toast); } SPZ.whenApiDefined(this.toast).then((apis) => { apis.showToast(content); }); } triggerEvent_(name, data) { const event = SPZUtils.Event.create(this.win, `${TAG}.${name}`, data); this.action_.trigger(this.element, name, event); } findBlockSectionPosition() { let current = this.element; while (current) { const dataSectionType = current.getAttribute(DATA_SECTION_TYPE); if ( dataSectionType === SECTION_TYPE_HEADER || dataSectionType === SECTION_TYPE_FOOTER ) { return dataSectionType; } current = current.parentElement; } return ''; } async initSettings_() { await this.getMarketThemeSettings_(); if (this.useCountrySelect_) { this.element.setAttribute('use-country-select', true); } if (this.useLanguageSelect_) { this.element.setAttribute('use-language-select', true); } if (this.useModal_) { this.element.setAttribute('use-modal', true); } if ( (this.useCountrySelect_ && !this.useLanguageSelect_) || (!this.useCountrySelect_ && this.useLanguageSelect_) ) { this.isSingleSelectMode_ = true; } this.blockSectionPosition_ = this.findBlockSectionPosition(); this.isPCLayout_ = this.win.matchMedia('(min-width: 960px)').matches; } renderMarketSelectTemplateNode_(clonedTemplate, data) { this.renderTemplateImg_(clonedTemplate, MARKET_FLAG, { src: data?.flag, width: '24', height: '24', }); this.renderTemplateElement_( clonedTemplate, MARKET_SELECT_VALUE, data.value ); this.renderTemplateElement_( clonedTemplate, MARKET_CURRENCY, data?.currency ); this.renderTemplateElement_( clonedTemplate, MARKET_CURRENCY_SYMBOL, data?.currencySymbol ); } bindDropdownOpenClickEvent_(triggerElement, dropdown) { if (!triggerElement) return; const triggerOpen = () => { SPZ.whenApiDefined(dropdown).then((apis) => { if (!dropdown.hasAttribute('open')) { apis.open(triggerElement); } }); }; if (this.isIOS_) { triggerElement.addEventListener('touchstart', triggerOpen); } else { triggerElement.addEventListener('click', triggerOpen); } } createDropdown_() { const dropdown = self.document.createElement('ljs-dropdown'); dropdown.setAttribute('layout', 'nodisplay'); if (this.blockSectionPosition_ === 'header') { dropdown.setAttribute('overlay-style', 'top: 4px;'); dropdown.setAttribute('placement', 'bottomRight'); } else if (this.blockSectionPosition_ === 'footer') { dropdown.setAttribute('overlay-style', 'top: -4px;'); dropdown.setAttribute('placement', 'top'); } return dropdown; } createDropdownIcon_() { const svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg"); svgElement.setAttribute("class", "market-rotate-180"); svgElement.setAttribute("width", "16"); svgElement.setAttribute("height", "16"); const path1 = document.createElementNS("http://www.w3.org/2000/svg", "path"); path1.setAttribute("d", "M7.47 5.172a.75.75 0 0 1 1.06 0l4.596 4.596a.75.75 0 1 1-1.06 1.06L7.468 6.232a.75.75 0 0 1 0-1.06Z"); path1.setAttribute("fill", "currentColor"); const path2 = document.createElementNS("http://www.w3.org/2000/svg", "path"); path2.setAttribute("d", "M8.533 5.172a.75.75 0 0 1 0 1.06l-4.596 4.596a.75.75 0 1 1-1.061-1.06l4.596-4.596a.75.75 0 0 1 1.06 0Z"); path2.setAttribute("fill", "currentColor"); svgElement.appendChild(path1); svgElement.appendChild(path2); return svgElement; } renderDropdownListWithClickEvent_({ triggerElement, dataList, subTitleRole, listElementWithTemplate, defaultValue, itemHandler, shouldUpdateSelectedItem = false, }) { const dropdown = this.createDropdown_(); const itemTemplate = SPZCore.Dom.scopedQuerySelector( listElementWithTemplate, 'template' ); const clonedItemTemplate = itemTemplate.cloneNode(true); const fragment = self.document.createDocumentFragment(); dataList.forEach((data) => { const tempParentNode = self.document.createElement('div'); const clonedTemplate = self.document.importNode( clonedItemTemplate.content, true ); tempParentNode.appendChild(clonedTemplate); tempParentNode.firstElementChild.classList.add( 'market-select-item' ); this.renderMarketSelectTemplateNode_(tempParentNode, data); const selectItemElement = SPZCore.Dom.scopedQuerySelector( tempParentNode, `[role="${MARKET_SELECT_ITEM}"]` ); if (!selectItemElement) { return; } if (defaultValue === data.value) { if (shouldUpdateSelectedItem) { const clonedSelectItemElement = selectItemElement.cloneNode(true); triggerElement.replaceChild( clonedSelectItemElement, triggerElement.firstElementChild ); } selectItemElement.setAttribute(PROPERTY_SELECTED, ''); } selectItemElement.setAttribute(MARKET_SELECT_ITEM_ID, data.value); fragment.appendChild(tempParentNode.firstElementChild); }); let value = defaultValue; listElementWithTemplate.addEventListener( 'click', (e) => { if (this.isEditMode) { this.showToast_('编辑器下不支持切换国家'); SPZ.whenApiDefined(dropdown).then((apis) => { apis.close(); }); return; } let targetElement = e.target; while (targetElement) { if ( !targetElement || targetElement.getAttribute(MARKET_SELECT_ITEM_ID) ) { break; } targetElement = targetElement.parentNode; } if ( !targetElement || !targetElement.hasAttribute(MARKET_SELECT_ITEM_ID) ) { return; } const selectValue = targetElement.getAttribute(MARKET_SELECT_ITEM_ID); if (value === selectValue) { SPZ.whenApiDefined(dropdown).then((apis) => { apis.close(); }); return; } const selectedData = dataList.find((c) => c.value === selectValue); if (shouldUpdateSelectedItem) { const tempParentNode = self.document.createElement('div'); const clonedTemplate = self.document.importNode( clonedItemTemplate.content, true ); tempParentNode.appendChild(clonedTemplate); this.renderMarketSelectTemplateNode_(tempParentNode, selectedData); tempParentNode.firstElementChild.classList.add( 'market-select-item' ); triggerElement.replaceChild( tempParentNode.firstElementChild, triggerElement.firstElementChild ); } value = selectValue; itemHandler?.(selectedData); SPZ.whenApiDefined(dropdown).then((apis) => { apis.close(); }); }, false ); listElementWithTemplate.removeChild(itemTemplate); listElementWithTemplate.appendChild(fragment); listElementWithTemplate.classList.add('market-select-list'); dropdown.appendChild(listElementWithTemplate); if (subTitleRole) { this.renderSelectTitle_(dropdown, subTitleRole); } return dropdown; } createSelect_({ parent, defaultValue, dataList, listElementWithTemplate, itemHandler, titleRole, }) { const triggerElement = self.document.createElement('div'); triggerElement.classList.add('market-select'); const displayElement = self.document.createElement('div'); triggerElement.appendChild(displayElement); triggerElement.appendChild(this.createDropdownIcon_()); const dropdown = this.renderDropdownListWithClickEvent_({ triggerElement, dataList, listElementWithTemplate, defaultValue, itemHandler, shouldUpdateSelectedItem: true, }); this.bindDropdownOpenClickEvent_(triggerElement, dropdown); const dropdownContainer = self.document.createElement('div'); dropdownContainer.appendChild(triggerElement); dropdownContainer.appendChild(dropdown); dropdownContainer.classList.add('market-select-container'); this.renderSelectTitle_(dropdownContainer, titleRole); parent.appendChild(dropdownContainer); } getListElementWithTemplate_(role) { const template = SPZCore.Dom.scopedQuerySelector( this.element, `[role="${role}"]` ); if (template) { const clonedTemplate = template.cloneNode(true); const tempParent = self.document.createElement("div"); tempParent.appendChild(clonedTemplate.content); const listElementWithTemplate = SPZCore.Dom.scopedQuerySelector( tempParent, `[role="${MARKET_SELECT_LIST}"]` ); return listElementWithTemplate; } return null; } renderSelectTitle_(parent, role) { if (!parent || !role) { return; } const template = SPZCore.Dom.scopedQuerySelector( this.element, `[role="${role}"]` ); const content = self.document.importNode(template.content, true); parent.insertBefore(content, parent.firstElementChild); parent.firstElementChild.classList.add( role.includes('sub') ? 'market-pc-header-select-sub-title' : 'market-pc-header-select-title' ); } initSelect_(rootNode, options) { const parent = rootNode || this.element; if (this.useCountrySelect_) { this.createSelect_({ parent, titleRole: options?.shouldRenderSelectTitle ? MARKET_PC_HEADER_COUNTRY_SELECT_TITLE : undefined, defaultValue: this.getDefaultCountryValue_(), dataList: this.marketCountryList.map(this.mapCountryRenderData_), listElementWithTemplate: this.getListElementWithTemplate_( MARKET_COUNTRY_SELECT ), itemHandler: this.handleCountrySelectChange_.bind(this), }); } if (this.useLanguageSelect_) { this.createSelect_({ parent, titleRole: options?.shouldRenderSelectTitle ? MARKET_PC_HEADER_LANGUAGE_SELECT_TITLE : undefined, defaultValue: this.getDefaultLanguageValue_(), dataList: this.marketLanguages.map(this.mapLanguageRenderData_), listElementWithTemplate: this.getListElementWithTemplate_( MARKET_LANGUAGE_SELECT ), itemHandler: this.handleLanguageSelectChange_.bind(this), }); } } initPcHeaderTriggerElement() { const headerTriggerElementTemplate = SPZCore.Dom.scopedQuerySelector( this.element, `[role="${MARKET_PC_HEADER_TRIGGER}"]` ); const headerTriggerElement = self.document.importNode( headerTriggerElementTemplate.content, true ); const parentDivElement = self.document.createElement('div'); parentDivElement.setAttribute('role', MARKET_PC_HEADER_TRIGGER); parentDivElement.appendChild(headerTriggerElement); this.element.removeChild(headerTriggerElementTemplate); return parentDivElement; } initPanelWithSelect_() { const triggerElement = this.initPcHeaderTriggerElement(); const dropdown = this.createDropdown_(); const panelElement = self.document.createElement('div'); panelElement.classList.add('market-panel'); this.initSelect_(panelElement, {shouldRenderSelectTitle: true}); dropdown.appendChild(panelElement); this.bindDropdownOpenClickEvent_(triggerElement, dropdown); this.element.appendChild(triggerElement); this.element.insertBefore(dropdown, triggerElement); } initSingleSelectDropdown_() { const triggerElement = this.initPcHeaderTriggerElement(); let dropdown; if (this.useCountrySelect_) { dropdown = this.renderDropdownListWithClickEvent_({ triggerElement, subTitleRole: MARKET_PC_HEADER_COUNTRY_SELECT_SUB_TITLE, dataList: this.marketCountryList.map(this.mapCountryRenderData_), listElementWithTemplate: this.getListElementWithTemplate_( MARKET_COUNTRY_SELECT ), defaultValue: this.getDefaultCountryValue_(), itemHandler: this.handleCountrySelectChange_.bind(this), }); } else if (this.useLanguageSelect_) { dropdown = this.renderDropdownListWithClickEvent_({ triggerElement, subTitleRole: MARKET_PC_HEADER_LANGUAGE_SELECT_SUB_TITLE, dataList: this.marketLanguages.map(this.mapLanguageRenderData_), listElementWithTemplate: this.getListElementWithTemplate_( MARKET_LANGUAGE_SELECT ), defaultValue: this.getDefaultLanguageValue_(), itemHandler: this.handleLanguageSelectChange_.bind(this), }); } if (dropdown) { this.bindDropdownOpenClickEvent_(triggerElement, dropdown); this.element.appendChild(triggerElement); this.element.appendChild(dropdown); } } initEntry_() { if (this.blockSectionPosition_ === SECTION_TYPE_HEADER) { if (this.isSingleSelectMode_) { this.initSingleSelectDropdown_(); } else if (this.useCountrySelect_ && this.useLanguageSelect_) { this.initPanelWithSelect_(); } } this.initSelect_(this.element); } async initData_() { const promises = []; if (this.useCountrySelect_ || this.useModal_) { promises.push(this.getCountryList_(), this.getIpMatchingMarket_()); } if (this.useLanguageSelect_) { promises.push(this.getMarketLanguages_(this.global.market.market_id)); } return Promise.all(promises).then((results) => { const ipMatchingMarket = results.find((result) => result.hasOwnProperty('matching_station') ); const marketCountryList = results.find((result) => result.hasOwnProperty('data') ); if (ipMatchingMarket && marketCountryList) { this.ipMatchingMarket = ipMatchingMarket?.matching_station?.find?.( (item) => item.type === 'multiple_market' ) || { img: marketCountryList.length ? marketCountryList?.[0]?.detail && marketCountryList[0].detail?.flag : '', }; } }); } initModal_() { if ( this.isEditMode || !this.ipMatchingMarket?.market_id || !this.useModal_ || this.hasCookie_(COOKIE_TIPS_NAME) || this.win[MARKET_MODAL_LOADED] ) { return; } this.win[MARKET_MODAL_LOADED] = true; const redirectParam = new URLSearchParams(this.win.location.search).get( URL_REDIRECT ); if (redirectParam) { this.initModalEntry_(MARKET_GATEWAY_REDIRECT_MODAL); } else if ( this.ipMatchingMarket.market_id !== this.global?.market?.market_id ) { this.initModalEntry_(MARKET_MODAL); } } async init_() { await this.initSettings_(); await this.initData_(); this.initEntry_(); this.initModal_(); } getDefaultCountryValue_() { return this.getCookie_(MARKET_COUNTRY_COOKIE) || this.marketCountryList[0]?.country_code; } mapCountryRenderData_(country) { return { flag: country?.detail?.flag || '', value: country?.country_code, currency: country?.currency, currencySymbol: country?.symbol?.val || '', url: country?.url, }; } handleCountrySelectChange_(selectedData) { this.setCookie_(MARKET_COUNTRY_COOKIE, selectedData.value); this.handleChangeURL_(selectedData.url); } getDefaultLanguageValue_() { return this.marketLanguages?.find?.( (lang) => lang.code === this.global?.market?.market_lang )?.name; } mapLanguageRenderData_(language) { return { value: language.name, url: language.url, }; } handleLanguageSelectChange_(selectedData) { this.handleChangeURL_(selectedData.url); } renderTemplateElement_(parent, role, value) { const elements = SPZCore.Dom.scopedQuerySelectorAll( parent, `[role="${role}"]` ); elements.forEach((element) => { if (element && value) { element.innerHTML = value; } }); } renderTemplateImg_(parent, role, options) { const flagElement = SPZCore.Dom.scopedQuerySelector( parent, `[role="${role}"]` ); if (flagElement && options?.src && options?.height && options?.width) { const spzImg = self.document.createElement('ljs-img'); spzImg.setAttribute('src', options.src); spzImg.setAttribute('layout', 'responsive'); spzImg.setAttribute('width', options.width); spzImg.setAttribute('height', options.height); spzImg.setAttribute( 'style', `width: ${options.width}px; height: ${options.height}px;` ); flagElement.appendChild(spzImg); } } handleChangeURL_(url) { if (!!url) { let {origin, pathname, search} = this.win.location; pathname = pathname.replace(SITE, url != '/' ? url : ''); this.win.location.href = `${origin}${pathname}${search}`; } else { this.win.location.reload(true); } } initModalEntry_(role) { const marketModalTemplate = SPZCore.Dom.scopedQuerySelector( this.element, `[role="${role}"]` ); if (marketModalTemplate) { const tempParentNode = self.document.createElement('div'); const clonedTemplate = self.document.importNode( marketModalTemplate.content, true ); tempParentNode.appendChild(clonedTemplate); this.renderTemplateImg_(tempParentNode, MARKET_MODAL_FLAG, { src: this.ipMatchingMarket?.img, width: '80', height: '80', }); this.renderTemplateElement_( tempParentNode, MARKET_MODAL_COUNTRY_CODE, this.ipMatchingMarket?.name ); this.renderTemplateElement_( tempParentNode, MARKET_MODAL_CURRENCY_SYMBOL, this.ipMatchingMarket?.currency_with_symbol ); const lightbox = self.document.createElement('ljs-lightbox'); lightbox.setAttribute('layout', 'nodisplay'); lightbox.appendChild(tempParentNode.firstElementChild); self.document.body.appendChild(lightbox); SPZ.whenApiDefined(lightbox).then((apis) => { SPZCore.Dom.scopedQuerySelectorAll( lightbox, `[role="${MARKET_MODAL_CLOSE}"]` ).forEach((ele) => { ele.addEventListener('click', () => { this.setCookie_(COOKIE_TIPS_NAME, 1, COOKIE_TIPS_EXPIRES); apis.close(); }); }); const marketModalConfirmElement = SPZCore.Dom.scopedQuerySelector( lightbox, `[role="${MARKET_MODAL_CONFIRM}"]` ); if (marketModalConfirmElement && this.ipMatchingMarket?.url) { marketModalConfirmElement.addEventListener('click', () => { this.setCookie_(COOKIE_TIPS_NAME, 1, COOKIE_TIPS_EXPIRES); this.setCookie_(MARKET_COUNTRY_COOKIE, this.ipMatchingMarket?.name); this.handleChangeURL_(this.ipMatchingMarket?.url); }); } const marketModalReselectElement = SPZCore.Dom.scopedQuerySelector( lightbox, `[role="${MARKET_MODAL_RESELECT}"]` ); if (marketModalReselectElement) { marketModalReselectElement.addEventListener('click', () => { this.setCookie_(COOKIE_TIPS_NAME, 1, COOKIE_TIPS_EXPIRES); const marketReselectTemplate = SPZCore.Dom.scopedQuerySelector( this.element, `[role="${MARKET_RESELECT_MODAL}"]` ); if (marketReselectTemplate && lightbox.firstElementChild) { const clonedTemplate = self.document.importNode( marketReselectTemplate.content, true ); const selectParent = SPZCore.Dom.scopedQuerySelector( clonedTemplate, `[role="${MARKET_MODAL_RESELECT_COUNTRY_SELECT}"]` ); if (selectParent) { this.createSelect_({ parent: selectParent, defaultValue: this.getDefaultCountryValue_(), dataList: this.marketCountryList.map( this.mapCountryRenderData_ ), listElementWithTemplate: this.getListElementWithTemplate_( MARKET_COUNTRY_SELECT ), itemHandler: this.handleCountrySelectChange_.bind(this), }); } lightbox.replaceChild(clonedTemplate, lightbox.firstElementChild); SPZCore.Dom.scopedQuerySelectorAll( lightbox, `[role="${MARKET_MODAL_CLOSE}"]` ).forEach((ele) => { ele.addEventListener('click', () => { this.setCookie_(COOKIE_TIPS_NAME, 1, COOKIE_TIPS_EXPIRES); apis.close(); }); }); } }); } apis.open(); }); } } async getMarketThemeSettings_() { return this.xhr_.fetchJson(MARKET_THEME_SETTINGS).then((res) => { this.useCountrySelect_ = !!res.country_selector_enabled; this.useLanguageSelect_ = !!res.language_selector_enabled && this.global?.market?.market_id; this.useModal_ = !!res.redirect_pop_enabled; return res; }); } async getCountryList_() { return this.xhr_.fetchJson(MARKET_COUNTRIES).then((res) => { this.marketCountryList = res.data.length ? res.data : []; return res; }); } async getIpMatchingMarket_() { return this.xhr_.fetchJson(IP_MATCHING_MARKET, { method: 'POST', body: { stations: [], }, }); } async getMarketLanguages_(marketId) { return this.xhr_ .fetchJson(MARKET_LANGUAGES.replace(/:id/gim, marketId)) .then((res) => { this.marketLanguages = res?.languages?.length ? res.languages : []; return res; }); } hasCookie_(name) { const m = self.document.cookie .split(';') .filter((pair) => pair.trim().startsWith(name + '=')); return !!(m && m[0]); } getCookie_(name) { const m = self.document.cookie .split(';') .filter((pair) => pair.trim().startsWith(name + '=')); return m && m[0] ? m[0].split('=')[1] : null; } setCookie_(name, value, expires) { const expiresDate = new Date(Date.now() + expires).toGMTString(); self.document.cookie = `${name}=${encodeURIComponent( value )};expires=${expiresDate};path=/`; } } SPZ.defineElement('spz-custom-market', SpzCustomMarket);
Region/Country
Region/Country
(
)
Language
Language
Switch to
based on your location
Purchase with
Get shipping options for
Set to
based on your location
Purchase with
Get shipping options for
Modify Country/Region
Log in
Create an account
${data.data && data.data.count}
SHOP ALL
Tops
Short Sleeve Shirts
Cotton And Linen Shirts 🔥
Long Sleeve Shirts
Hoodies & Sweatshirts
Jackets & Coats 🔥
Long Sleeved T-Shirt
Polo Shirts👕
V-Neck Suit Vest/Tuxedo Waistcoat And Tie
100% Cotton Tees
Shirt with Breast Pocket
Bottoms
Men's Short Sets
Shorts
Pants
Customized Gift 🎁
Holidays & Occasions
Short Sleeve Shirts
Sweatshirts
Tees
Baseball Caps
Accessories
Socks
Belts & Suspenders
Shoes
Chic Matching Set
Dresses 👗
NEW
SHOP BY CATRGORY
New in Short Sleeve Shirts
New in Hawaiian Shirts
New in Cotton And Linen Shirts
SHOP BY DATE
12/30/2024
12/23/2024
12/16/2024
12/02/2024
Best Seller
HOLIDAY & OCCASIONS 🥂
Mardi Gras Shirts 🎭
Valentine's Day Shirts 💕
St. Patrick's Day Shirts ☘
Cute Cartoon Shirts 🤠
Costume Ideas
Easter Day Shirts ✝️
Cinco De Mayo 💃
LGBT Pride Month 🏳️🌈
Happy Father's Day🎁
Hippie Shirts ☮
Patriots' Day Shirts
Oktoberfest🍺
Columbus Day ⚓
Veterans Day ✈️
Thanksgiving Day Tops 🦃
Halloween's Day Shirts 🎃🕸️
Christmas Eve Shirts 🎄
New Year Shirts 🎉
Short Sleeve Shirts
Shop By Category
Short Sleeve Shirts
Cotton And Linen Shirts
Shirt with Breast Pocket
Tees
Polos
Tuxedo Waistcoat And Tie
Shop By Features
Hot Sale 🔥
Customized 🎨
Funny Holiday
Costume Shirts🦸♂
70's Style 🎵
50‘s Style🔥
Fighter Series🛩️
Ukiyo-e 🌊
Sports 🏈
Music 🎸
Hippie Style
Hawaiian Shirts 🏄
Vintage Pin Up Girl Poster
Resort🏖️
Car 🏁🏎
Flag
BBQ
Shop By Pattern
Cat 😸
Dog 🐕
Duck 🦆
Dragon 🐲
Gorilla 🦍
Flamingo 🦩
Shop By Pattern
Leaves 🍃
Flowers 🌸
Octopus 🐙
Western Cowboy 🤠
Tattoo
Skull 💀
LONG SLEEVE TOPS
Long Sleeve Shirts
Hoodies & Sweatshirts
Jackets & Coats
Long Sleeve Polos
Long Sleeve T-Shirts
Personalized Customized 🎁
Holidays & Occasions
Short Sleeve Shirts
Tees
Sweatshirts
Baseball Caps
Flash Sale ⚡
SHOP BY PRICE
34% Off New Arrivals
Down to $9.9
Sales
Sale Shirts - Clearance
Sale Dresses - Clearance
Sale Waistcoat - Clearance
Sale Coats - Clearance
SURPRISE BOX 🎁
More links
${(function(){ const formatLinks = (links) => { return links.map(link => { link.tag = tags[link.title.toUpperCase()] || {}; link.target_attr = link.target == '_blank' ? 'target="_blank"' : ''; link.href_attr = link.url ? `href="${link.url}"` : ''; if(link.children && link.children.length){ link.children = formatLinks(link.children); } return link; }) }; const tags = {"HOT SALE":{"label":"HOT","bg":"#E62405","color":"#FFFFFF"}}; let linkList = [ { id: 73641645, title: "SHOP ALL", url: "\/collections\/all-new", target: "_blank", levels: 2, product0: { id: (null) }, children: [ { title: "Tops", url: "\/collections\/tops-new", target: "_blank", levels: 1, children: [ { title: "Short Sleeve Shirts", url: "\/collections\/short-sleeve-shirts-5gd2", target: "_blank", levels: 0, }, { title: "Cotton And Linen Shirts \ud83d\udd25", url: "\/collections\/cotton-and-linen-shirts", target: "_blank", levels: 0, }, { title: "Long Sleeve Shirts", url: "\/collections\/long-sleeve-shirts", target: "_blank", levels: 0, }, { title: "Hoodies & Sweatshirts", url: "\/collections\/hoodies-sweatshirts", target: "_blank", levels: 0, }, { title: "Jackets & Coats \ud83d\udd25", url: "\/collections\/jackets-coats", target: "_blank", levels: 0, }, { title: "Long Sleeved T-Shirt", url: "\/collections\/long-sleeved-t-shirt", target: "_blank", levels: 0, }, { title: "Polo Shirts\ud83d\udc55", url: "\/collections\/polo-shirts", target: "_blank", levels: 0, }, { title: "V-Neck Suit Vest\/Tuxedo Waistcoat And Tie", url: "\/collections\/v-neck-suit-vest-tuxedo-waistcoat-and-tie", target: "_blank", levels: 0, }, { title: "100% Cotton Tees", url: "\/collections\/new-in-100-cotton-tees", target: "_blank", levels: 0, }, { title: "Shirt with Breast Pocket", url: "\/collections\/shirt-with-breast-pocket", target: "_blank", levels: 0, }, ] }, { title: "Bottoms", url: "\/collections\/bottoms", target: "_blank", levels: 1, children: [ { title: "Men's Short Sets", url: "\/collections\/short-sets", target: "_blank", levels: 0, }, { title: "Shorts", url: "\/collections\/shorts-new", target: "_blank", levels: 0, }, { title: "Pants", url: "\/collections\/pants", target: "_blank", levels: 0, }, ] }, { title: "Customized Gift \ud83c\udf81", url: "\/collections\/customized", target: "_blank", levels: 1, children: [ { title: "Holidays & Occasions", url: "\/collections\/holidays-occasions", target: "_blank", levels: 0, }, { title: "Short Sleeve Shirts", url: "\/collections\/customized-short-sleeve-shirts", target: "_blank", levels: 0, }, { title: "Sweatshirts", url: "\/collections\/customized-sweatshirts", target: "_blank", levels: 0, }, { title: "Tees", url: "\/collections\/customized-100-cotton-tees", target: "_blank", levels: 0, }, { title: "Baseball Caps", url: "\/collections\/customized-baseball-caps", target: "_blank", levels: 0, }, ] }, { title: "Accessories", url: "\/collections\/accessories", target: "_blank", levels: 1, children: [ { title: "Socks", url: "\/collections\/socks", target: "_blank", levels: 0, }, { title: "Belts & Suspenders", url: "\/collections\/belts-suspenders", target: "_blank", levels: 0, }, { title: "Shoes", url: "\/collections\/shoes", target: "_blank", levels: 0, }, ] }, { title: "Chic Matching Set", url: "\/collections\/two-piece-set", target: "_blank", levels: 0, children: [ ] }, { title: "Dresses \ud83d\udc57", url: "\/collections\/womens-dresses", target: "_blank", levels: 0, children: [ ] }, ] }, { id: 73641701, title: "NEW", url: "\/collections\/new-arrivals", target: "_blank", levels: 2, product0: { id: (null) }, children: [ { title: "SHOP BY CATRGORY", url: "", target: "", levels: 1, children: [ { title: "New in Short Sleeve Shirts", url: "\/collections\/new-in-short-sleeve-shirts", target: "_blank", levels: 0, }, { title: "New in Hawaiian Shirts", url: "\/collections\/new-in-hawaiian-shirts", target: "_blank", levels: 0, }, { title: "New in Cotton And Linen Shirts", url: "\/collections\/new-in-cotton-and-linen-shirts", target: "_blank", levels: 0, }, ] }, { title: "SHOP BY DATE", url: "", target: "", levels: 1, children: [ { title: "12\/30\/2024", url: "\/collections\/12-30-2024", target: "_blank", levels: 0, }, { title: "12\/23\/2024", url: "\/collections\/12-23-2024", target: "_blank", levels: 0, }, { title: "12\/16\/2024", url: "\/collections\/12-16-2024", target: "_blank", levels: 0, }, { title: "12\/02\/2024", url: "\/collections\/12-02-2024", target: "_blank", levels: 0, }, ] }, ] }, { id: 73641723, title: "Best Seller", url: "\/collections\/best-selling", target: "_blank", levels: 0, product0: { id: (null) }, children: [ ] }, { id: 73641725, title: "HOLIDAY & OCCASIONS \ud83e\udd42", url: "\/collections\/holidays", target: "_blank", levels: 1, product0: { id: (null) }, children: [ { title: "Mardi Gras Shirts \ud83c\udfad", url: "\/collections\/mardi-gras-shirts-1", target: "_blank", levels: 0, children: [ ] }, { title: "Valentine's Day Shirts \ud83d\udc95", url: "\/collections\/valentines-day-shirts", target: "_blank", levels: 0, children: [ ] }, { title: "St. Patrick's Day Shirts \u2618", url: "\/collections\/st-patricks-day", target: "_blank", levels: 0, children: [ ] }, { title: "Cute Cartoon Shirts \ud83e\udd20", url: "\/collections\/cartoon-costume-shirts-new", target: "_blank", levels: 0, children: [ ] }, { title: "Costume Ideas", url: "\/collections\/costume-ideas", target: "_blank", levels: 0, children: [ ] }, { title: "Easter Day Shirts \u271d\ufe0f", url: "\/collections\/easter-series", target: "_blank", levels: 0, children: [ ] }, { title: "Cinco De Mayo \ud83d\udc83", url: "\/collections\/cinco-de-mayo", target: "_blank", levels: 0, children: [ ] }, { title: "LGBT Pride Month \ud83c\udff3\ufe0f\u200d\ud83c\udf08", url: "\/collections\/rainbow-series-new", target: "_blank", levels: 0, children: [ ] }, { title: "Happy Father's Day\ud83c\udf81", url: "\/collections\/happy-fathers-day", target: "_blank", levels: 0, children: [ ] }, { title: "Hippie Shirts \u262e", url: "\/collections\/hippie-festival", target: "_blank", levels: 0, children: [ ] }, { title: "Patriots' Day Shirts", url: "\/collections\/nation", target: "_blank", levels: 0, children: [ ] }, { title: "Oktoberfest\ud83c\udf7a", url: "\/collections\/oktoberfest", target: "_blank", levels: 0, children: [ ] }, { title: "Columbus Day \u2693", url: "\/collections\/columbus-day", target: "_blank", levels: 0, children: [ ] }, { title: "Veterans Day \u2708\ufe0f", url: "\/collections\/fighter-series", target: "_blank", levels: 0, children: [ ] }, { title: "Thanksgiving Day Tops \ud83e\udd83", url: "\/collections\/thanksgiving-tops", target: "_blank", levels: 0, children: [ ] }, { title: "Halloween's Day Shirts \ud83c\udf83\ud83d\udd78\ufe0f", url: "\/collections\/halloweens-party", target: "_blank", levels: 0, children: [ ] }, { title: "Christmas Eve Shirts \ud83c\udf84", url: "\/collections\/christmas", target: "_blank", levels: 0, children: [ ] }, { title: "New Year Shirts \ud83c\udf89", url: "\/collections\/new-year-shirts", target: "_blank", levels: 0, children: [ ] }, ] }, { id: 73641765, title: "Short Sleeve Shirts", url: "\/collections\/short-sleeve-shirts-5gd2", target: "_blank", levels: 2, product0: { id: (null) }, children: [ { title: "Shop By Category", url: "", target: "", levels: 1, children: [ { title: "Short Sleeve Shirts", url: "\/collections\/short-sleeve-shirts-5gd2", target: "_blank", levels: 0, }, { title: "Cotton And Linen Shirts", url: "\/collections\/cotton-and-linen-shirts", target: "_blank", levels: 0, }, { title: "Shirt with Breast Pocket", url: "\/collections\/shirts-with-breast-pocket-new", target: "_blank", levels: 0, }, { title: "Tees", url: "\/collections\/tees", target: "_blank", levels: 0, }, { title: "Polos", url: "\/collections\/polos-new", target: "_blank", levels: 0, }, { title: "Tuxedo Waistcoat And Tie", url: "\/collections\/v-neck-suit-vest-tuxedo-waistcoat-and-tie", target: "_blank", levels: 0, }, ] }, { title: "Shop By Features", url: "", target: "", levels: 1, children: [ { title: "Hot Sale \ud83d\udd25", url: "\/collections\/hot-sale-new", target: "_blank", levels: 0, }, { title: "Customized \ud83c\udfa8", url: "\/collections\/customized", target: "_blank", levels: 0, }, { title: "Funny Holiday ", url: "\/collections\/holidays", target: "_blank", levels: 0, }, { title: "Costume Shirts\ud83e\uddb8\u200d\u2642", url: "\/collections\/cartoon-costume-shirts-new", target: "_blank", levels: 0, }, { title: "70's Style \ud83c\udfb5", url: "\/collections\/70s-style-shirts-new", target: "_blank", levels: 0, }, { title: "50\u2018s Style\ud83d\udd25", url: "\/collections\/retro-style-shirts-new", target: "_blank", levels: 0, }, { title: "Fighter Series\ud83d\udee9\ufe0f", url: "\/collections\/fighter-series", target: "_blank", levels: 0, }, { title: "Ukiyo-e \ud83c\udf0a", url: "\/collections\/art-style-ukiyo-e-printed-new", target: "_blank", levels: 0, }, { title: "Sports \ud83c\udfc8", url: "\/collections\/sports", target: "_blank", levels: 0, }, { title: "Music \ud83c\udfb8", url: "\/collections\/musical-style", target: "_blank", levels: 0, }, { title: "Hippie Style", url: "\/collections\/hippie-festival", target: "_blank", levels: 0, }, { title: "Hawaiian Shirts \ud83c\udfc4", url: "\/collections\/hawaiian-style", target: "_blank", levels: 0, }, { title: "Vintage Pin Up Girl Poster", url: "\/collections\/beauties-print", target: "_blank", levels: 0, }, { title: "Resort\ud83c\udfd6\ufe0f", url: "\/collections\/resort-shirts-new", target: "_blank", levels: 0, }, { title: "Car \ud83c\udfc1\ud83c\udfce", url: "\/collections\/cars", target: "_blank", levels: 0, }, { title: "Flag ", url: "\/collections\/nation", target: "_blank", levels: 0, }, { title: "BBQ", url: "\/collections\/bbq", target: "_blank", levels: 0, }, ] }, { title: "Shop By Pattern", url: "", target: "", levels: 1, children: [ { title: "Cat \ud83d\ude38", url: "\/collections\/cat-series", target: "_blank", levels: 0, }, { title: "Dog \ud83d\udc15", url: "\/collections\/dog", target: "_blank", levels: 0, }, { title: "Duck \ud83e\udd86", url: "\/collections\/duck", target: "_blank", levels: 0, }, { title: "Dragon \ud83d\udc32", url: "\/collections\/dragon-design", target: "_blank", levels: 0, }, { title: "Gorilla \ud83e\udd8d", url: "\/collections\/gorilla", target: "_blank", levels: 0, }, { title: "Flamingo \ud83e\udda9", url: "\/collections\/flamingo", target: "_blank", levels: 0, }, ] }, { title: "Shop By Pattern", url: "", target: "", levels: 1, children: [ { title: "Leaves \ud83c\udf43", url: "\/collections\/plants", target: "_blank", levels: 0, }, { title: "Flowers \ud83c\udf38", url: "\/collections\/floral-print", target: "_blank", levels: 0, }, { title: "Octopus \ud83d\udc19", url: "\/collections\/octopus", target: "_blank", levels: 0, }, { title: "Western Cowboy \ud83e\udd20", url: "\/collections\/cowboy-style", target: "_blank", levels: 0, }, { title: "Tattoo ", url: "\/collections\/tattoo", target: "_blank", levels: 0, }, { title: "Skull \ud83d\udc80", url: "\/collections\/skull-series", target: "_blank", levels: 0, }, ] }, ] }, { id: 73641913, title: "LONG SLEEVE TOPS", url: "\/collections\/long-sleeve", target: "_blank", levels: 1, product0: { id: (null) }, children: [ { title: "Long Sleeve Shirts", url: "\/collections\/long-sleeve-shirts", target: "_blank", levels: 0, children: [ ] }, { title: "Hoodies & Sweatshirts", url: "\/collections\/hoodies-sweatshirts", target: "_blank", levels: 0, children: [ ] }, { title: "Jackets & Coats", url: "\/collections\/jackets-coats", target: "_blank", levels: 0, children: [ ] }, { title: "Long Sleeve Polos", url: "\/collections\/long-sleeve-polos", target: "_blank", levels: 0, children: [ ] }, { title: "Long Sleeve T-Shirts", url: "\/collections\/long-sleeved-t-shirt", target: "_blank", levels: 0, children: [ ] }, ] }, { id: 73641927, title: "Personalized Customized \ud83c\udf81", url: "\/collections\/customized", target: "_blank", levels: 1, product0: { id: (null) }, children: [ { title: "Holidays & Occasions", url: "\/collections\/holidays-occasions", target: "_blank", levels: 0, children: [ ] }, { title: "Short Sleeve Shirts", url: "\/collections\/customized-short-sleeve-shirts", target: "_blank", levels: 0, children: [ ] }, { title: "Tees", url: "\/collections\/customized-100-cotton-tees", target: "_blank", levels: 0, children: [ ] }, { title: "Sweatshirts", url: "\/collections\/customized-sweatshirts", target: "_blank", levels: 0, children: [ ] }, { title: "Baseball Caps", url: "\/collections\/customized-baseball-caps", target: "_blank", levels: 0, children: [ ] }, ] }, { id: 73641949, title: "Flash Sale \u26a1", url: "\/collections\/flash-sale", target: "_blank", levels: 2, product0: { id: (null) }, children: [ { title: "SHOP BY PRICE", url: "", target: "", levels: 1, children: [ { title: "34% Off New Arrivals", url: "\/collections\/flash-sale", target: "_blank", levels: 0, }, { title: "Down to $9.9", url: "\/collections\/up-to-9-9", target: "_blank", levels: 0, }, ] }, { title: "Sales", url: "\/collections\/on-sale-items-1", target: "_blank", levels: 1, children: [ { title: "Sale Shirts - Clearance", url: "\/collections\/sale-shirts", target: "_blank", levels: 0, }, { title: "Sale Dresses - Clearance", url: "\/collections\/sale-dresses", target: "_blank", levels: 0, }, { title: "Sale Waistcoat - Clearance", url: "\/collections\/sale-waistcoat", target: "_blank", levels: 0, }, { title: "Sale Coats - Clearance", url: "\/collections\/sale-coats", target: "_blank", levels: 0, }, ] }, { title: "SURPRISE BOX \ud83c\udf81", url: "\/collections\/blind-box", target: "_blank", levels: 0, children: [ ] }, ] }, ].slice(offset); linkList = formatLinks(linkList); const hasChild = linkList.some(link => !!(link.children && link.children.length || link.product0.id)); return `
${link.title}
${link.tag.label}
${second_link.title}
${second_link.tag.label}
${third_links.title}
${third_links.tag.label}
${link.title}
${link.tag.label}
` })()}
SHOP ALL
Tops
Short Sleeve Shirts
Cotton And Linen Shirts 🔥
Long Sleeve Shirts
Hoodies & Sweatshirts
Jackets & Coats 🔥
Long Sleeved T-Shirt
Polo Shirts👕
V-Neck Suit Vest/Tuxedo Waistcoat And Tie
100% Cotton Tees
Shirt with Breast Pocket
Bottoms
Men's Short Sets
Shorts
Pants
Customized Gift 🎁
Holidays & Occasions
Short Sleeve Shirts
Sweatshirts
Tees
Baseball Caps
Accessories
Socks
Belts & Suspenders
Shoes
Chic Matching Set
Dresses 👗
NEW
SHOP BY CATRGORY
New in Short Sleeve Shirts
New in Hawaiian Shirts
New in Cotton And Linen Shirts
SHOP BY DATE
12/30/2024
12/23/2024
12/16/2024
12/02/2024
Best Seller
HOLIDAY & OCCASIONS 🥂
Mardi Gras Shirts 🎭
Valentine's Day Shirts 💕
St. Patrick's Day Shirts ☘
Cute Cartoon Shirts 🤠
Costume Ideas
Easter Day Shirts ✝️
Cinco De Mayo 💃
LGBT Pride Month 🏳️🌈
Happy Father's Day🎁
Hippie Shirts ☮
Patriots' Day Shirts
Oktoberfest🍺
Columbus Day ⚓
Veterans Day ✈️
Thanksgiving Day Tops 🦃
Halloween's Day Shirts 🎃🕸️
Christmas Eve Shirts 🎄
New Year Shirts 🎉
Short Sleeve Shirts
Shop By Category
Short Sleeve Shirts
Cotton And Linen Shirts
Shirt with Breast Pocket
Tees
Polos
Tuxedo Waistcoat And Tie
Shop By Features
Hot Sale 🔥
Customized 🎨
Funny Holiday
Costume Shirts🦸♂
70's Style 🎵
50‘s Style🔥
Fighter Series🛩️
Ukiyo-e 🌊
Sports 🏈
Music 🎸
Hippie Style
Hawaiian Shirts 🏄
Vintage Pin Up Girl Poster
Resort🏖️
Car 🏁🏎
Flag
BBQ
Shop By Pattern
Cat 😸
Dog 🐕
Duck 🦆
Dragon 🐲
Gorilla 🦍
Flamingo 🦩
Shop By Pattern
Leaves 🍃
Flowers 🌸
Octopus 🐙
Western Cowboy 🤠
Tattoo
Skull 💀
LONG SLEEVE TOPS
Long Sleeve Shirts
Hoodies & Sweatshirts
Jackets & Coats
Long Sleeve Polos
Long Sleeve T-Shirts
Personalized Customized 🎁
Holidays & Occasions
Short Sleeve Shirts
Tees
Sweatshirts
Baseball Caps
Flash Sale ⚡
SHOP BY PRICE
34% Off New Arrivals
Down to $9.9
Sales
Sale Shirts - Clearance
Sale Dresses - Clearance
Sale Waistcoat - Clearance
Sale Coats - Clearance
SURPRISE BOX 🎁
More links
${(function(){ const formatLinks = (links) => { return links.map(link => { link.tag = tags[link.title.toUpperCase()] || {}; link.target_attr = link.target == '_blank' ? 'target="_blank"' : ''; link.href_attr = link.url ? `href="${link.url}"` : ''; if(link.children && link.children.length){ link.children = formatLinks(link.children); } return link; }) }; const tags = {"HOT SALE":{"label":"HOT","bg":"#E62405","color":"#FFFFFF"}}; let linkList = [ { id: 73641645, title: "SHOP ALL", url: "\/collections\/all-new", target: "_blank", levels: 2, product0: { id: (null) }, children: [ { title: "Tops", url: "\/collections\/tops-new", target: "_blank", levels: 1, children: [ { title: "Short Sleeve Shirts", url: "\/collections\/short-sleeve-shirts-5gd2", target: "_blank", levels: 0, }, { title: "Cotton And Linen Shirts \ud83d\udd25", url: "\/collections\/cotton-and-linen-shirts", target: "_blank", levels: 0, }, { title: "Long Sleeve Shirts", url: "\/collections\/long-sleeve-shirts", target: "_blank", levels: 0, }, { title: "Hoodies & Sweatshirts", url: "\/collections\/hoodies-sweatshirts", target: "_blank", levels: 0, }, { title: "Jackets & Coats \ud83d\udd25", url: "\/collections\/jackets-coats", target: "_blank", levels: 0, }, { title: "Long Sleeved T-Shirt", url: "\/collections\/long-sleeved-t-shirt", target: "_blank", levels: 0, }, { title: "Polo Shirts\ud83d\udc55", url: "\/collections\/polo-shirts", target: "_blank", levels: 0, }, { title: "V-Neck Suit Vest\/Tuxedo Waistcoat And Tie", url: "\/collections\/v-neck-suit-vest-tuxedo-waistcoat-and-tie", target: "_blank", levels: 0, }, { title: "100% Cotton Tees", url: "\/collections\/new-in-100-cotton-tees", target: "_blank", levels: 0, }, { title: "Shirt with Breast Pocket", url: "\/collections\/shirt-with-breast-pocket", target: "_blank", levels: 0, }, ] }, { title: "Bottoms", url: "\/collections\/bottoms", target: "_blank", levels: 1, children: [ { title: "Men's Short Sets", url: "\/collections\/short-sets", target: "_blank", levels: 0, }, { title: "Shorts", url: "\/collections\/shorts-new", target: "_blank", levels: 0, }, { title: "Pants", url: "\/collections\/pants", target: "_blank", levels: 0, }, ] }, { title: "Customized Gift \ud83c\udf81", url: "\/collections\/customized", target: "_blank", levels: 1, children: [ { title: "Holidays & Occasions", url: "\/collections\/holidays-occasions", target: "_blank", levels: 0, }, { title: "Short Sleeve Shirts", url: "\/collections\/customized-short-sleeve-shirts", target: "_blank", levels: 0, }, { title: "Sweatshirts", url: "\/collections\/customized-sweatshirts", target: "_blank", levels: 0, }, { title: "Tees", url: "\/collections\/customized-100-cotton-tees", target: "_blank", levels: 0, }, { title: "Baseball Caps", url: "\/collections\/customized-baseball-caps", target: "_blank", levels: 0, }, ] }, { title: "Accessories", url: "\/collections\/accessories", target: "_blank", levels: 1, children: [ { title: "Socks", url: "\/collections\/socks", target: "_blank", levels: 0, }, { title: "Belts & Suspenders", url: "\/collections\/belts-suspenders", target: "_blank", levels: 0, }, { title: "Shoes", url: "\/collections\/shoes", target: "_blank", levels: 0, }, ] }, { title: "Chic Matching Set", url: "\/collections\/two-piece-set", target: "_blank", levels: 0, children: [ ] }, { title: "Dresses \ud83d\udc57", url: "\/collections\/womens-dresses", target: "_blank", levels: 0, children: [ ] }, ] }, { id: 73641701, title: "NEW", url: "\/collections\/new-arrivals", target: "_blank", levels: 2, product0: { id: (null) }, children: [ { title: "SHOP BY CATRGORY", url: "", target: "", levels: 1, children: [ { title: "New in Short Sleeve Shirts", url: "\/collections\/new-in-short-sleeve-shirts", target: "_blank", levels: 0, }, { title: "New in Hawaiian Shirts", url: "\/collections\/new-in-hawaiian-shirts", target: "_blank", levels: 0, }, { title: "New in Cotton And Linen Shirts", url: "\/collections\/new-in-cotton-and-linen-shirts", target: "_blank", levels: 0, }, ] }, { title: "SHOP BY DATE", url: "", target: "", levels: 1, children: [ { title: "12\/30\/2024", url: "\/collections\/12-30-2024", target: "_blank", levels: 0, }, { title: "12\/23\/2024", url: "\/collections\/12-23-2024", target: "_blank", levels: 0, }, { title: "12\/16\/2024", url: "\/collections\/12-16-2024", target: "_blank", levels: 0, }, { title: "12\/02\/2024", url: "\/collections\/12-02-2024", target: "_blank", levels: 0, }, ] }, ] }, { id: 73641723, title: "Best Seller", url: "\/collections\/best-selling", target: "_blank", levels: 0, product0: { id: (null) }, children: [ ] }, { id: 73641725, title: "HOLIDAY & OCCASIONS \ud83e\udd42", url: "\/collections\/holidays", target: "_blank", levels: 1, product0: { id: (null) }, children: [ { title: "Mardi Gras Shirts \ud83c\udfad", url: "\/collections\/mardi-gras-shirts-1", target: "_blank", levels: 0, children: [ ] }, { title: "Valentine's Day Shirts \ud83d\udc95", url: "\/collections\/valentines-day-shirts", target: "_blank", levels: 0, children: [ ] }, { title: "St. Patrick's Day Shirts \u2618", url: "\/collections\/st-patricks-day", target: "_blank", levels: 0, children: [ ] }, { title: "Cute Cartoon Shirts \ud83e\udd20", url: "\/collections\/cartoon-costume-shirts-new", target: "_blank", levels: 0, children: [ ] }, { title: "Costume Ideas", url: "\/collections\/costume-ideas", target: "_blank", levels: 0, children: [ ] }, { title: "Easter Day Shirts \u271d\ufe0f", url: "\/collections\/easter-series", target: "_blank", levels: 0, children: [ ] }, { title: "Cinco De Mayo \ud83d\udc83", url: "\/collections\/cinco-de-mayo", target: "_blank", levels: 0, children: [ ] }, { title: "LGBT Pride Month \ud83c\udff3\ufe0f\u200d\ud83c\udf08", url: "\/collections\/rainbow-series-new", target: "_blank", levels: 0, children: [ ] }, { title: "Happy Father's Day\ud83c\udf81", url: "\/collections\/happy-fathers-day", target: "_blank", levels: 0, children: [ ] }, { title: "Hippie Shirts \u262e", url: "\/collections\/hippie-festival", target: "_blank", levels: 0, children: [ ] }, { title: "Patriots' Day Shirts", url: "\/collections\/nation", target: "_blank", levels: 0, children: [ ] }, { title: "Oktoberfest\ud83c\udf7a", url: "\/collections\/oktoberfest", target: "_blank", levels: 0, children: [ ] }, { title: "Columbus Day \u2693", url: "\/collections\/columbus-day", target: "_blank", levels: 0, children: [ ] }, { title: "Veterans Day \u2708\ufe0f", url: "\/collections\/fighter-series", target: "_blank", levels: 0, children: [ ] }, { title: "Thanksgiving Day Tops \ud83e\udd83", url: "\/collections\/thanksgiving-tops", target: "_blank", levels: 0, children: [ ] }, { title: "Halloween's Day Shirts \ud83c\udf83\ud83d\udd78\ufe0f", url: "\/collections\/halloweens-party", target: "_blank", levels: 0, children: [ ] }, { title: "Christmas Eve Shirts \ud83c\udf84", url: "\/collections\/christmas", target: "_blank", levels: 0, children: [ ] }, { title: "New Year Shirts \ud83c\udf89", url: "\/collections\/new-year-shirts", target: "_blank", levels: 0, children: [ ] }, ] }, { id: 73641765, title: "Short Sleeve Shirts", url: "\/collections\/short-sleeve-shirts-5gd2", target: "_blank", levels: 2, product0: { id: (null) }, children: [ { title: "Shop By Category", url: "", target: "", levels: 1, children: [ { title: "Short Sleeve Shirts", url: "\/collections\/short-sleeve-shirts-5gd2", target: "_blank", levels: 0, }, { title: "Cotton And Linen Shirts", url: "\/collections\/cotton-and-linen-shirts", target: "_blank", levels: 0, }, { title: "Shirt with Breast Pocket", url: "\/collections\/shirts-with-breast-pocket-new", target: "_blank", levels: 0, }, { title: "Tees", url: "\/collections\/tees", target: "_blank", levels: 0, }, { title: "Polos", url: "\/collections\/polos-new", target: "_blank", levels: 0, }, { title: "Tuxedo Waistcoat And Tie", url: "\/collections\/v-neck-suit-vest-tuxedo-waistcoat-and-tie", target: "_blank", levels: 0, }, ] }, { title: "Shop By Features", url: "", target: "", levels: 1, children: [ { title: "Hot Sale \ud83d\udd25", url: "\/collections\/hot-sale-new", target: "_blank", levels: 0, }, { title: "Customized \ud83c\udfa8", url: "\/collections\/customized", target: "_blank", levels: 0, }, { title: "Funny Holiday ", url: "\/collections\/holidays", target: "_blank", levels: 0, }, { title: "Costume Shirts\ud83e\uddb8\u200d\u2642", url: "\/collections\/cartoon-costume-shirts-new", target: "_blank", levels: 0, }, { title: "70's Style \ud83c\udfb5", url: "\/collections\/70s-style-shirts-new", target: "_blank", levels: 0, }, { title: "50\u2018s Style\ud83d\udd25", url: "\/collections\/retro-style-shirts-new", target: "_blank", levels: 0, }, { title: "Fighter Series\ud83d\udee9\ufe0f", url: "\/collections\/fighter-series", target: "_blank", levels: 0, }, { title: "Ukiyo-e \ud83c\udf0a", url: "\/collections\/art-style-ukiyo-e-printed-new", target: "_blank", levels: 0, }, { title: "Sports \ud83c\udfc8", url: "\/collections\/sports", target: "_blank", levels: 0, }, { title: "Music \ud83c\udfb8", url: "\/collections\/musical-style", target: "_blank", levels: 0, }, { title: "Hippie Style", url: "\/collections\/hippie-festival", target: "_blank", levels: 0, }, { title: "Hawaiian Shirts \ud83c\udfc4", url: "\/collections\/hawaiian-style", target: "_blank", levels: 0, }, { title: "Vintage Pin Up Girl Poster", url: "\/collections\/beauties-print", target: "_blank", levels: 0, }, { title: "Resort\ud83c\udfd6\ufe0f", url: "\/collections\/resort-shirts-new", target: "_blank", levels: 0, }, { title: "Car \ud83c\udfc1\ud83c\udfce", url: "\/collections\/cars", target: "_blank", levels: 0, }, { title: "Flag ", url: "\/collections\/nation", target: "_blank", levels: 0, }, { title: "BBQ", url: "\/collections\/bbq", target: "_blank", levels: 0, }, ] }, { title: "Shop By Pattern", url: "", target: "", levels: 1, children: [ { title: "Cat \ud83d\ude38", url: "\/collections\/cat-series", target: "_blank", levels: 0, }, { title: "Dog \ud83d\udc15", url: "\/collections\/dog", target: "_blank", levels: 0, }, { title: "Duck \ud83e\udd86", url: "\/collections\/duck", target: "_blank", levels: 0, }, { title: "Dragon \ud83d\udc32", url: "\/collections\/dragon-design", target: "_blank", levels: 0, }, { title: "Gorilla \ud83e\udd8d", url: "\/collections\/gorilla", target: "_blank", levels: 0, }, { title: "Flamingo \ud83e\udda9", url: "\/collections\/flamingo", target: "_blank", levels: 0, }, ] }, { title: "Shop By Pattern", url: "", target: "", levels: 1, children: [ { title: "Leaves \ud83c\udf43", url: "\/collections\/plants", target: "_blank", levels: 0, }, { title: "Flowers \ud83c\udf38", url: "\/collections\/floral-print", target: "_blank", levels: 0, }, { title: "Octopus \ud83d\udc19", url: "\/collections\/octopus", target: "_blank", levels: 0, }, { title: "Western Cowboy \ud83e\udd20", url: "\/collections\/cowboy-style", target: "_blank", levels: 0, }, { title: "Tattoo ", url: "\/collections\/tattoo", target: "_blank", levels: 0, }, { title: "Skull \ud83d\udc80", url: "\/collections\/skull-series", target: "_blank", levels: 0, }, ] }, ] }, { id: 73641913, title: "LONG SLEEVE TOPS", url: "\/collections\/long-sleeve", target: "_blank", levels: 1, product0: { id: (null) }, children: [ { title: "Long Sleeve Shirts", url: "\/collections\/long-sleeve-shirts", target: "_blank", levels: 0, children: [ ] }, { title: "Hoodies & Sweatshirts", url: "\/collections\/hoodies-sweatshirts", target: "_blank", levels: 0, children: [ ] }, { title: "Jackets & Coats", url: "\/collections\/jackets-coats", target: "_blank", levels: 0, children: [ ] }, { title: "Long Sleeve Polos", url: "\/collections\/long-sleeve-polos", target: "_blank", levels: 0, children: [ ] }, { title: "Long Sleeve T-Shirts", url: "\/collections\/long-sleeved-t-shirt", target: "_blank", levels: 0, children: [ ] }, ] }, { id: 73641927, title: "Personalized Customized \ud83c\udf81", url: "\/collections\/customized", target: "_blank", levels: 1, product0: { id: (null) }, children: [ { title: "Holidays & Occasions", url: "\/collections\/holidays-occasions", target: "_blank", levels: 0, children: [ ] }, { title: "Short Sleeve Shirts", url: "\/collections\/customized-short-sleeve-shirts", target: "_blank", levels: 0, children: [ ] }, { title: "Tees", url: "\/collections\/customized-100-cotton-tees", target: "_blank", levels: 0, children: [ ] }, { title: "Sweatshirts", url: "\/collections\/customized-sweatshirts", target: "_blank", levels: 0, children: [ ] }, { title: "Baseball Caps", url: "\/collections\/customized-baseball-caps", target: "_blank", levels: 0, children: [ ] }, ] }, { id: 73641949, title: "Flash Sale \u26a1", url: "\/collections\/flash-sale", target: "_blank", levels: 2, product0: { id: (null) }, children: [ { title: "SHOP BY PRICE", url: "", target: "", levels: 1, children: [ { title: "34% Off New Arrivals", url: "\/collections\/flash-sale", target: "_blank", levels: 0, }, { title: "Down to $9.9", url: "\/collections\/up-to-9-9", target: "_blank", levels: 0, }, ] }, { title: "Sales", url: "\/collections\/on-sale-items-1", target: "_blank", levels: 1, children: [ { title: "Sale Shirts - Clearance", url: "\/collections\/sale-shirts", target: "_blank", levels: 0, }, { title: "Sale Dresses - Clearance", url: "\/collections\/sale-dresses", target: "_blank", levels: 0, }, { title: "Sale Waistcoat - Clearance", url: "\/collections\/sale-waistcoat", target: "_blank", levels: 0, }, { title: "Sale Coats - Clearance", url: "\/collections\/sale-coats", target: "_blank", levels: 0, }, ] }, { title: "SURPRISE BOX \ud83c\udf81", url: "\/collections\/blind-box", target: "_blank", levels: 0, children: [ ] }, ] }, ].slice(offset); linkList = formatLinks(linkList); const hasChild = linkList.some(link => !!(link.children && link.children.length || link.product0.id)); return `
${link.title}
${link.tag.label}
${second_link.title}
${second_link.tag.label}
${third_links.title}
${third_links.tag.label}
${link.title}
${link.tag.label}
` })()}
const marketSlot = document.querySelector(".plugin_c_market"); if(marketSlot) { marketSlot.remove(); }
const SITE = (window.C_SETTINGS || window[atob('U0hPUExBWlpB')])?.routes?.root || ''; const MARKET_THEME_SETTINGS = `${SITE}/api/markets/theme_setting`; const MARKET_COUNTRIES = `${SITE}/api/markets/countries`; const IP_MATCHING_MARKET = `${SITE}/api/front/station`; const MARKET_LANGUAGES = `${SITE}/api/markets/:id/active_languages`; const URL_REDIRECT = '_market_redirected'; const COOKIE_TIPS_NAME = 'market_no_tips'; const COOKIE_TIPS_EXPIRES = 1000 * 60 * 60 * 24 * 14; const MARKET_COUNTRY_COOKIE = '_shoplazza_market_country'; const MARKET_MODAL_LOADED = '__market_modal_loaded__'; const PROPERTY_SELECTED = 'selected'; const MARKET_PC_HEADER_TRIGGER = 'market-pc-header-trigger'; const MARKET_PC_HEADER_COUNTRY_SELECT_TITLE = 'market-pc-header-country-select-title'; const MARKET_PC_HEADER_LANGUAGE_SELECT_TITLE = 'market-pc-header-language-select-title'; const MARKET_PC_HEADER_LANGUAGE_SELECT_SUB_TITLE = 'market-pc-header-language-select-sub-title'; const MARKET_PC_HEADER_COUNTRY_SELECT_SUB_TITLE = 'market-pc-header-country-select-sub-title'; const MARKET_FLAG = 'market-flag'; const MARKET_SELECT_VALUE = 'market-select-value'; const MARKET_CURRENCY = 'market-currency'; const MARKET_CURRENCY_SYMBOL = 'market-currency-symbol'; const MARKET_SELECT_ITEM = 'market-select-item'; const MARKET_SELECT_ITEM_ID = 'market-select-item-id'; const MARKET_SELECT_LIST = 'market-select-list'; const MARKET_LANGUAGE_SELECT = 'market-language-select'; const MARKET_COUNTRY_SELECT = 'market-country-select'; const MARKET_MODAL = 'market-modal'; const MARKET_GATEWAY_REDIRECT_MODAL = 'market-gateway-redirect-modal'; const MARKET_RESELECT_MODAL = 'market-reselect-modal'; const MARKET_MODAL_FLAG = 'market-modal-flag'; const MARKET_MODAL_COUNTRY_CODE = 'market-modal-country-code'; const MARKET_MODAL_CURRENCY_SYMBOL = 'market-modal-currency-symbol'; const MARKET_MODAL_CLOSE = 'market-modal-close'; const MARKET_MODAL_CONFIRM = 'market-modal-confirm'; const MARKET_MODAL_RESELECT = 'market-modal-reselect'; const MARKET_MODAL_RESELECT_COUNTRY_SELECT = 'market-modal-reselect-country-select'; const DATA_SECTION_TYPE = 'data-section-type'; const SECTION_TYPE_HEADER = 'header'; const SECTION_TYPE_FOOTER = 'footer'; class SpzCustomMarket extends SPZ.BaseElement { constructor(element) { super(element); this.global = null; this.useCountrySelect_ = false; this.useLanguageSelect_ = false; this.useModal_ = false; this.isSingleSelectMode_ = false; this.blockSectionPosition_ = ''; this.isEditMode = false; this.ipMatchingMarket = null; this.marketCountryList = []; this.marketLanguages = []; this.toast = null; } static deferredMount() { return false; } isLayoutSupported(layout) { return layout == SPZCore.Layout.LOGIC; } buildCallback() { console.debug('Geolocation'); this.xhr_ = SPZServices.xhrFor(this.win); const platform = SPZServices.platformFor(this.win); this.isIOS_ = platform.isIos(); this.action_ = SPZServices.actionServiceForDoc(this.element); this.global = this.win.C_SETTINGS || this.win[atob('U0hPUExBWlpB')]; this.isEditMode = new URLSearchParams(this.win.location.search).get('preview_theme_id') && new URLSearchParams(this.win.location.search).get('oseid'); this.init_(); } showToast_(content) { if (!this.toast) { this.toast = self.document.createElement('ljs-toast'); this.toast.setAttribute('layout', 'nodisplay'); this.toast.setAttribute('hidden', ''); this.toast.setAttribute('duration', '2000'); this.element.appendChild(this.toast); } SPZ.whenApiDefined(this.toast).then((apis) => { apis.showToast(content); }); } triggerEvent_(name, data) { const event = SPZUtils.Event.create(this.win, `${TAG}.${name}`, data); this.action_.trigger(this.element, name, event); } findBlockSectionPosition() { let current = this.element; while (current) { const dataSectionType = current.getAttribute(DATA_SECTION_TYPE); if ( dataSectionType === SECTION_TYPE_HEADER || dataSectionType === SECTION_TYPE_FOOTER ) { return dataSectionType; } current = current.parentElement; } return ''; } async initSettings_() { await this.getMarketThemeSettings_(); if (this.useCountrySelect_) { this.element.setAttribute('use-country-select', true); } if (this.useLanguageSelect_) { this.element.setAttribute('use-language-select', true); } if (this.useModal_) { this.element.setAttribute('use-modal', true); } if ( (this.useCountrySelect_ && !this.useLanguageSelect_) || (!this.useCountrySelect_ && this.useLanguageSelect_) ) { this.isSingleSelectMode_ = true; } this.blockSectionPosition_ = this.findBlockSectionPosition(); this.isPCLayout_ = this.win.matchMedia('(min-width: 960px)').matches; } renderMarketSelectTemplateNode_(clonedTemplate, data) { this.renderTemplateImg_(clonedTemplate, MARKET_FLAG, { src: data?.flag, width: '24', height: '24', }); this.renderTemplateElement_( clonedTemplate, MARKET_SELECT_VALUE, data.value ); this.renderTemplateElement_( clonedTemplate, MARKET_CURRENCY, data?.currency ); this.renderTemplateElement_( clonedTemplate, MARKET_CURRENCY_SYMBOL, data?.currencySymbol ); } bindDropdownOpenClickEvent_(triggerElement, dropdown) { if (!triggerElement) return; const triggerOpen = () => { SPZ.whenApiDefined(dropdown).then((apis) => { if (!dropdown.hasAttribute('open')) { apis.open(triggerElement); } }); }; if (this.isIOS_) { triggerElement.addEventListener('touchstart', triggerOpen); } else { triggerElement.addEventListener('click', triggerOpen); } } createDropdown_() { const dropdown = self.document.createElement('ljs-dropdown'); dropdown.setAttribute('layout', 'nodisplay'); if (this.blockSectionPosition_ === 'header') { dropdown.setAttribute('overlay-style', 'top: 4px;'); dropdown.setAttribute('placement', 'bottomRight'); } else if (this.blockSectionPosition_ === 'footer') { dropdown.setAttribute('overlay-style', 'top: -4px;'); dropdown.setAttribute('placement', 'top'); } return dropdown; } createDropdownIcon_() { const svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg"); svgElement.setAttribute("class", "market-rotate-180"); svgElement.setAttribute("width", "16"); svgElement.setAttribute("height", "16"); const path1 = document.createElementNS("http://www.w3.org/2000/svg", "path"); path1.setAttribute("d", "M7.47 5.172a.75.75 0 0 1 1.06 0l4.596 4.596a.75.75 0 1 1-1.06 1.06L7.468 6.232a.75.75 0 0 1 0-1.06Z"); path1.setAttribute("fill", "currentColor"); const path2 = document.createElementNS("http://www.w3.org/2000/svg", "path"); path2.setAttribute("d", "M8.533 5.172a.75.75 0 0 1 0 1.06l-4.596 4.596a.75.75 0 1 1-1.061-1.06l4.596-4.596a.75.75 0 0 1 1.06 0Z"); path2.setAttribute("fill", "currentColor"); svgElement.appendChild(path1); svgElement.appendChild(path2); return svgElement; } renderDropdownListWithClickEvent_({ triggerElement, dataList, subTitleRole, listElementWithTemplate, defaultValue, itemHandler, shouldUpdateSelectedItem = false, }) { const dropdown = this.createDropdown_(); const itemTemplate = SPZCore.Dom.scopedQuerySelector( listElementWithTemplate, 'template' ); const clonedItemTemplate = itemTemplate.cloneNode(true); const fragment = self.document.createDocumentFragment(); dataList.forEach((data) => { const tempParentNode = self.document.createElement('div'); const clonedTemplate = self.document.importNode( clonedItemTemplate.content, true ); tempParentNode.appendChild(clonedTemplate); tempParentNode.firstElementChild.classList.add( 'market-select-item' ); this.renderMarketSelectTemplateNode_(tempParentNode, data); const selectItemElement = SPZCore.Dom.scopedQuerySelector( tempParentNode, `[role="${MARKET_SELECT_ITEM}"]` ); if (!selectItemElement) { return; } if (defaultValue === data.value) { if (shouldUpdateSelectedItem) { const clonedSelectItemElement = selectItemElement.cloneNode(true); triggerElement.replaceChild( clonedSelectItemElement, triggerElement.firstElementChild ); } selectItemElement.setAttribute(PROPERTY_SELECTED, ''); } selectItemElement.setAttribute(MARKET_SELECT_ITEM_ID, data.value); fragment.appendChild(tempParentNode.firstElementChild); }); let value = defaultValue; listElementWithTemplate.addEventListener( 'click', (e) => { if (this.isEditMode) { this.showToast_('编辑器下不支持切换国家'); SPZ.whenApiDefined(dropdown).then((apis) => { apis.close(); }); return; } let targetElement = e.target; while (targetElement) { if ( !targetElement || targetElement.getAttribute(MARKET_SELECT_ITEM_ID) ) { break; } targetElement = targetElement.parentNode; } if ( !targetElement || !targetElement.hasAttribute(MARKET_SELECT_ITEM_ID) ) { return; } const selectValue = targetElement.getAttribute(MARKET_SELECT_ITEM_ID); if (value === selectValue) { SPZ.whenApiDefined(dropdown).then((apis) => { apis.close(); }); return; } const selectedData = dataList.find((c) => c.value === selectValue); if (shouldUpdateSelectedItem) { const tempParentNode = self.document.createElement('div'); const clonedTemplate = self.document.importNode( clonedItemTemplate.content, true ); tempParentNode.appendChild(clonedTemplate); this.renderMarketSelectTemplateNode_(tempParentNode, selectedData); tempParentNode.firstElementChild.classList.add( 'market-select-item' ); triggerElement.replaceChild( tempParentNode.firstElementChild, triggerElement.firstElementChild ); } value = selectValue; itemHandler?.(selectedData); SPZ.whenApiDefined(dropdown).then((apis) => { apis.close(); }); }, false ); listElementWithTemplate.removeChild(itemTemplate); listElementWithTemplate.appendChild(fragment); listElementWithTemplate.classList.add('market-select-list'); dropdown.appendChild(listElementWithTemplate); if (subTitleRole) { this.renderSelectTitle_(dropdown, subTitleRole); } return dropdown; } createSelect_({ parent, defaultValue, dataList, listElementWithTemplate, itemHandler, titleRole, }) { const triggerElement = self.document.createElement('div'); triggerElement.classList.add('market-select'); const displayElement = self.document.createElement('div'); triggerElement.appendChild(displayElement); triggerElement.appendChild(this.createDropdownIcon_()); const dropdown = this.renderDropdownListWithClickEvent_({ triggerElement, dataList, listElementWithTemplate, defaultValue, itemHandler, shouldUpdateSelectedItem: true, }); this.bindDropdownOpenClickEvent_(triggerElement, dropdown); const dropdownContainer = self.document.createElement('div'); dropdownContainer.appendChild(triggerElement); dropdownContainer.appendChild(dropdown); dropdownContainer.classList.add('market-select-container'); this.renderSelectTitle_(dropdownContainer, titleRole); parent.appendChild(dropdownContainer); } getListElementWithTemplate_(role) { const template = SPZCore.Dom.scopedQuerySelector( this.element, `[role="${role}"]` ); if (template) { const clonedTemplate = template.cloneNode(true); const tempParent = self.document.createElement("div"); tempParent.appendChild(clonedTemplate.content); const listElementWithTemplate = SPZCore.Dom.scopedQuerySelector( tempParent, `[role="${MARKET_SELECT_LIST}"]` ); return listElementWithTemplate; } return null; } renderSelectTitle_(parent, role) { if (!parent || !role) { return; } const template = SPZCore.Dom.scopedQuerySelector( this.element, `[role="${role}"]` ); const content = self.document.importNode(template.content, true); parent.insertBefore(content, parent.firstElementChild); parent.firstElementChild.classList.add( role.includes('sub') ? 'market-pc-header-select-sub-title' : 'market-pc-header-select-title' ); } initSelect_(rootNode, options) { const parent = rootNode || this.element; if (this.useCountrySelect_) { this.createSelect_({ parent, titleRole: options?.shouldRenderSelectTitle ? MARKET_PC_HEADER_COUNTRY_SELECT_TITLE : undefined, defaultValue: this.getDefaultCountryValue_(), dataList: this.marketCountryList.map(this.mapCountryRenderData_), listElementWithTemplate: this.getListElementWithTemplate_( MARKET_COUNTRY_SELECT ), itemHandler: this.handleCountrySelectChange_.bind(this), }); } if (this.useLanguageSelect_) { this.createSelect_({ parent, titleRole: options?.shouldRenderSelectTitle ? MARKET_PC_HEADER_LANGUAGE_SELECT_TITLE : undefined, defaultValue: this.getDefaultLanguageValue_(), dataList: this.marketLanguages.map(this.mapLanguageRenderData_), listElementWithTemplate: this.getListElementWithTemplate_( MARKET_LANGUAGE_SELECT ), itemHandler: this.handleLanguageSelectChange_.bind(this), }); } } initPcHeaderTriggerElement() { const headerTriggerElementTemplate = SPZCore.Dom.scopedQuerySelector( this.element, `[role="${MARKET_PC_HEADER_TRIGGER}"]` ); const headerTriggerElement = self.document.importNode( headerTriggerElementTemplate.content, true ); const parentDivElement = self.document.createElement('div'); parentDivElement.setAttribute('role', MARKET_PC_HEADER_TRIGGER); parentDivElement.appendChild(headerTriggerElement); this.element.removeChild(headerTriggerElementTemplate); return parentDivElement; } initPanelWithSelect_() { const triggerElement = this.initPcHeaderTriggerElement(); const dropdown = this.createDropdown_(); const panelElement = self.document.createElement('div'); panelElement.classList.add('market-panel'); this.initSelect_(panelElement, {shouldRenderSelectTitle: true}); dropdown.appendChild(panelElement); this.bindDropdownOpenClickEvent_(triggerElement, dropdown); this.element.appendChild(triggerElement); this.element.insertBefore(dropdown, triggerElement); } initSingleSelectDropdown_() { const triggerElement = this.initPcHeaderTriggerElement(); let dropdown; if (this.useCountrySelect_) { dropdown = this.renderDropdownListWithClickEvent_({ triggerElement, subTitleRole: MARKET_PC_HEADER_COUNTRY_SELECT_SUB_TITLE, dataList: this.marketCountryList.map(this.mapCountryRenderData_), listElementWithTemplate: this.getListElementWithTemplate_( MARKET_COUNTRY_SELECT ), defaultValue: this.getDefaultCountryValue_(), itemHandler: this.handleCountrySelectChange_.bind(this), }); } else if (this.useLanguageSelect_) { dropdown = this.renderDropdownListWithClickEvent_({ triggerElement, subTitleRole: MARKET_PC_HEADER_LANGUAGE_SELECT_SUB_TITLE, dataList: this.marketLanguages.map(this.mapLanguageRenderData_), listElementWithTemplate: this.getListElementWithTemplate_( MARKET_LANGUAGE_SELECT ), defaultValue: this.getDefaultLanguageValue_(), itemHandler: this.handleLanguageSelectChange_.bind(this), }); } if (dropdown) { this.bindDropdownOpenClickEvent_(triggerElement, dropdown); this.element.appendChild(triggerElement); this.element.appendChild(dropdown); } } initEntry_() { if (this.blockSectionPosition_ === SECTION_TYPE_HEADER) { if (this.isSingleSelectMode_) { this.initSingleSelectDropdown_(); } else if (this.useCountrySelect_ && this.useLanguageSelect_) { this.initPanelWithSelect_(); } } this.initSelect_(this.element); } async initData_() { const promises = []; if (this.useCountrySelect_ || this.useModal_) { promises.push(this.getCountryList_(), this.getIpMatchingMarket_()); } if (this.useLanguageSelect_) { promises.push(this.getMarketLanguages_(this.global.market.market_id)); } return Promise.all(promises).then((results) => { const ipMatchingMarket = results.find((result) => result.hasOwnProperty('matching_station') ); const marketCountryList = results.find((result) => result.hasOwnProperty('data') ); if (ipMatchingMarket && marketCountryList) { this.ipMatchingMarket = ipMatchingMarket?.matching_station?.find?.( (item) => item.type === 'multiple_market' ) || { img: marketCountryList.length ? marketCountryList?.[0]?.detail && marketCountryList[0].detail?.flag : '', }; } }); } initModal_() { if ( this.isEditMode || !this.ipMatchingMarket?.market_id || !this.useModal_ || this.hasCookie_(COOKIE_TIPS_NAME) || this.win[MARKET_MODAL_LOADED] ) { return; } this.win[MARKET_MODAL_LOADED] = true; const redirectParam = new URLSearchParams(this.win.location.search).get( URL_REDIRECT ); if (redirectParam) { this.initModalEntry_(MARKET_GATEWAY_REDIRECT_MODAL); } else if ( this.ipMatchingMarket.market_id !== this.global?.market?.market_id ) { this.initModalEntry_(MARKET_MODAL); } } async init_() { await this.initSettings_(); await this.initData_(); this.initEntry_(); this.initModal_(); } getDefaultCountryValue_() { return this.getCookie_(MARKET_COUNTRY_COOKIE) || this.marketCountryList[0]?.country_code; } mapCountryRenderData_(country) { return { flag: country?.detail?.flag || '', value: country?.country_code, currency: country?.currency, currencySymbol: country?.symbol?.val || '', url: country?.url, }; } handleCountrySelectChange_(selectedData) { this.setCookie_(MARKET_COUNTRY_COOKIE, selectedData.value); this.handleChangeURL_(selectedData.url); } getDefaultLanguageValue_() { return this.marketLanguages?.find?.( (lang) => lang.code === this.global?.market?.market_lang )?.name; } mapLanguageRenderData_(language) { return { value: language.name, url: language.url, }; } handleLanguageSelectChange_(selectedData) { this.handleChangeURL_(selectedData.url); } renderTemplateElement_(parent, role, value) { const elements = SPZCore.Dom.scopedQuerySelectorAll( parent, `[role="${role}"]` ); elements.forEach((element) => { if (element && value) { element.innerHTML = value; } }); } renderTemplateImg_(parent, role, options) { const flagElement = SPZCore.Dom.scopedQuerySelector( parent, `[role="${role}"]` ); if (flagElement && options?.src && options?.height && options?.width) { const spzImg = self.document.createElement('ljs-img'); spzImg.setAttribute('src', options.src); spzImg.setAttribute('layout', 'responsive'); spzImg.setAttribute('width', options.width); spzImg.setAttribute('height', options.height); spzImg.setAttribute( 'style', `width: ${options.width}px; height: ${options.height}px;` ); flagElement.appendChild(spzImg); } } handleChangeURL_(url) { if (!!url) { let {origin, pathname, search} = this.win.location; pathname = pathname.replace(SITE, url != '/' ? url : ''); this.win.location.href = `${origin}${pathname}${search}`; } else { this.win.location.reload(true); } } initModalEntry_(role) { const marketModalTemplate = SPZCore.Dom.scopedQuerySelector( this.element, `[role="${role}"]` ); if (marketModalTemplate) { const tempParentNode = self.document.createElement('div'); const clonedTemplate = self.document.importNode( marketModalTemplate.content, true ); tempParentNode.appendChild(clonedTemplate); this.renderTemplateImg_(tempParentNode, MARKET_MODAL_FLAG, { src: this.ipMatchingMarket?.img, width: '80', height: '80', }); this.renderTemplateElement_( tempParentNode, MARKET_MODAL_COUNTRY_CODE, this.ipMatchingMarket?.name ); this.renderTemplateElement_( tempParentNode, MARKET_MODAL_CURRENCY_SYMBOL, this.ipMatchingMarket?.currency_with_symbol ); const lightbox = self.document.createElement('ljs-lightbox'); lightbox.setAttribute('layout', 'nodisplay'); lightbox.appendChild(tempParentNode.firstElementChild); self.document.body.appendChild(lightbox); SPZ.whenApiDefined(lightbox).then((apis) => { SPZCore.Dom.scopedQuerySelectorAll( lightbox, `[role="${MARKET_MODAL_CLOSE}"]` ).forEach((ele) => { ele.addEventListener('click', () => { this.setCookie_(COOKIE_TIPS_NAME, 1, COOKIE_TIPS_EXPIRES); apis.close(); }); }); const marketModalConfirmElement = SPZCore.Dom.scopedQuerySelector( lightbox, `[role="${MARKET_MODAL_CONFIRM}"]` ); if (marketModalConfirmElement && this.ipMatchingMarket?.url) { marketModalConfirmElement.addEventListener('click', () => { this.setCookie_(COOKIE_TIPS_NAME, 1, COOKIE_TIPS_EXPIRES); this.setCookie_(MARKET_COUNTRY_COOKIE, this.ipMatchingMarket?.name); this.handleChangeURL_(this.ipMatchingMarket?.url); }); } const marketModalReselectElement = SPZCore.Dom.scopedQuerySelector( lightbox, `[role="${MARKET_MODAL_RESELECT}"]` ); if (marketModalReselectElement) { marketModalReselectElement.addEventListener('click', () => { this.setCookie_(COOKIE_TIPS_NAME, 1, COOKIE_TIPS_EXPIRES); const marketReselectTemplate = SPZCore.Dom.scopedQuerySelector( this.element, `[role="${MARKET_RESELECT_MODAL}"]` ); if (marketReselectTemplate && lightbox.firstElementChild) { const clonedTemplate = self.document.importNode( marketReselectTemplate.content, true ); const selectParent = SPZCore.Dom.scopedQuerySelector( clonedTemplate, `[role="${MARKET_MODAL_RESELECT_COUNTRY_SELECT}"]` ); if (selectParent) { this.createSelect_({ parent: selectParent, defaultValue: this.getDefaultCountryValue_(), dataList: this.marketCountryList.map( this.mapCountryRenderData_ ), listElementWithTemplate: this.getListElementWithTemplate_( MARKET_COUNTRY_SELECT ), itemHandler: this.handleCountrySelectChange_.bind(this), }); } lightbox.replaceChild(clonedTemplate, lightbox.firstElementChild); SPZCore.Dom.scopedQuerySelectorAll( lightbox, `[role="${MARKET_MODAL_CLOSE}"]` ).forEach((ele) => { ele.addEventListener('click', () => { this.setCookie_(COOKIE_TIPS_NAME, 1, COOKIE_TIPS_EXPIRES); apis.close(); }); }); } }); } apis.open(); }); } } async getMarketThemeSettings_() { return this.xhr_.fetchJson(MARKET_THEME_SETTINGS).then((res) => { this.useCountrySelect_ = !!res.country_selector_enabled; this.useLanguageSelect_ = !!res.language_selector_enabled && this.global?.market?.market_id; this.useModal_ = !!res.redirect_pop_enabled; return res; }); } async getCountryList_() { return this.xhr_.fetchJson(MARKET_COUNTRIES).then((res) => { this.marketCountryList = res.data.length ? res.data : []; return res; }); } async getIpMatchingMarket_() { return this.xhr_.fetchJson(IP_MATCHING_MARKET, { method: 'POST', body: { stations: [], }, }); } async getMarketLanguages_(marketId) { return this.xhr_ .fetchJson(MARKET_LANGUAGES.replace(/:id/gim, marketId)) .then((res) => { this.marketLanguages = res?.languages?.length ? res.languages : []; return res; }); } hasCookie_(name) { const m = self.document.cookie .split(';') .filter((pair) => pair.trim().startsWith(name + '=')); return !!(m && m[0]); } getCookie_(name) { const m = self.document.cookie .split(';') .filter((pair) => pair.trim().startsWith(name + '=')); return m && m[0] ? m[0].split('=')[1] : null; } setCookie_(name, value, expires) { const expiresDate = new Date(Date.now() + expires).toGMTString(); self.document.cookie = `${name}=${encodeURIComponent( value )};expires=${expiresDate};path=/`; } } SPZ.defineElement('spz-custom-market', SpzCustomMarket);
Region/Country
Region/Country
(
)
Language
Language
Switch to
based on your location
Purchase with
Get shipping options for
Set to
based on your location
Purchase with
Get shipping options for
Modify Country/Region
const marketSlot = document.querySelector(".plugin_c_market"); if(marketSlot) { marketSlot.remove(); }
const SITE = (window.C_SETTINGS || window[atob('U0hPUExBWlpB')])?.routes?.root || ''; const MARKET_THEME_SETTINGS = `${SITE}/api/markets/theme_setting`; const MARKET_COUNTRIES = `${SITE}/api/markets/countries`; const IP_MATCHING_MARKET = `${SITE}/api/front/station`; const MARKET_LANGUAGES = `${SITE}/api/markets/:id/active_languages`; const URL_REDIRECT = '_market_redirected'; const COOKIE_TIPS_NAME = 'market_no_tips'; const COOKIE_TIPS_EXPIRES = 1000 * 60 * 60 * 24 * 14; const MARKET_COUNTRY_COOKIE = '_shoplazza_market_country'; const MARKET_MODAL_LOADED = '__market_modal_loaded__'; const PROPERTY_SELECTED = 'selected'; const MARKET_PC_HEADER_TRIGGER = 'market-pc-header-trigger'; const MARKET_PC_HEADER_COUNTRY_SELECT_TITLE = 'market-pc-header-country-select-title'; const MARKET_PC_HEADER_LANGUAGE_SELECT_TITLE = 'market-pc-header-language-select-title'; const MARKET_PC_HEADER_LANGUAGE_SELECT_SUB_TITLE = 'market-pc-header-language-select-sub-title'; const MARKET_PC_HEADER_COUNTRY_SELECT_SUB_TITLE = 'market-pc-header-country-select-sub-title'; const MARKET_FLAG = 'market-flag'; const MARKET_SELECT_VALUE = 'market-select-value'; const MARKET_CURRENCY = 'market-currency'; const MARKET_CURRENCY_SYMBOL = 'market-currency-symbol'; const MARKET_SELECT_ITEM = 'market-select-item'; const MARKET_SELECT_ITEM_ID = 'market-select-item-id'; const MARKET_SELECT_LIST = 'market-select-list'; const MARKET_LANGUAGE_SELECT = 'market-language-select'; const MARKET_COUNTRY_SELECT = 'market-country-select'; const MARKET_MODAL = 'market-modal'; const MARKET_GATEWAY_REDIRECT_MODAL = 'market-gateway-redirect-modal'; const MARKET_RESELECT_MODAL = 'market-reselect-modal'; const MARKET_MODAL_FLAG = 'market-modal-flag'; const MARKET_MODAL_COUNTRY_CODE = 'market-modal-country-code'; const MARKET_MODAL_CURRENCY_SYMBOL = 'market-modal-currency-symbol'; const MARKET_MODAL_CLOSE = 'market-modal-close'; const MARKET_MODAL_CONFIRM = 'market-modal-confirm'; const MARKET_MODAL_RESELECT = 'market-modal-reselect'; const MARKET_MODAL_RESELECT_COUNTRY_SELECT = 'market-modal-reselect-country-select'; const DATA_SECTION_TYPE = 'data-section-type'; const SECTION_TYPE_HEADER = 'header'; const SECTION_TYPE_FOOTER = 'footer'; class SpzCustomMarket extends SPZ.BaseElement { constructor(element) { super(element); this.global = null; this.useCountrySelect_ = false; this.useLanguageSelect_ = false; this.useModal_ = false; this.isSingleSelectMode_ = false; this.blockSectionPosition_ = ''; this.isEditMode = false; this.ipMatchingMarket = null; this.marketCountryList = []; this.marketLanguages = []; this.toast = null; } static deferredMount() { return false; } isLayoutSupported(layout) { return layout == SPZCore.Layout.LOGIC; } buildCallback() { console.debug('Geolocation'); this.xhr_ = SPZServices.xhrFor(this.win); const platform = SPZServices.platformFor(this.win); this.isIOS_ = platform.isIos(); this.action_ = SPZServices.actionServiceForDoc(this.element); this.global = this.win.C_SETTINGS || this.win[atob('U0hPUExBWlpB')]; this.isEditMode = new URLSearchParams(this.win.location.search).get('preview_theme_id') && new URLSearchParams(this.win.location.search).get('oseid'); this.init_(); } showToast_(content) { if (!this.toast) { this.toast = self.document.createElement('ljs-toast'); this.toast.setAttribute('layout', 'nodisplay'); this.toast.setAttribute('hidden', ''); this.toast.setAttribute('duration', '2000'); this.element.appendChild(this.toast); } SPZ.whenApiDefined(this.toast).then((apis) => { apis.showToast(content); }); } triggerEvent_(name, data) { const event = SPZUtils.Event.create(this.win, `${TAG}.${name}`, data); this.action_.trigger(this.element, name, event); } findBlockSectionPosition() { let current = this.element; while (current) { const dataSectionType = current.getAttribute(DATA_SECTION_TYPE); if ( dataSectionType === SECTION_TYPE_HEADER || dataSectionType === SECTION_TYPE_FOOTER ) { return dataSectionType; } current = current.parentElement; } return ''; } async initSettings_() { await this.getMarketThemeSettings_(); if (this.useCountrySelect_) { this.element.setAttribute('use-country-select', true); } if (this.useLanguageSelect_) { this.element.setAttribute('use-language-select', true); } if (this.useModal_) { this.element.setAttribute('use-modal', true); } if ( (this.useCountrySelect_ && !this.useLanguageSelect_) || (!this.useCountrySelect_ && this.useLanguageSelect_) ) { this.isSingleSelectMode_ = true; } this.blockSectionPosition_ = this.findBlockSectionPosition(); this.isPCLayout_ = this.win.matchMedia('(min-width: 960px)').matches; } renderMarketSelectTemplateNode_(clonedTemplate, data) { this.renderTemplateImg_(clonedTemplate, MARKET_FLAG, { src: data?.flag, width: '24', height: '24', }); this.renderTemplateElement_( clonedTemplate, MARKET_SELECT_VALUE, data.value ); this.renderTemplateElement_( clonedTemplate, MARKET_CURRENCY, data?.currency ); this.renderTemplateElement_( clonedTemplate, MARKET_CURRENCY_SYMBOL, data?.currencySymbol ); } bindDropdownOpenClickEvent_(triggerElement, dropdown) { if (!triggerElement) return; const triggerOpen = () => { SPZ.whenApiDefined(dropdown).then((apis) => { if (!dropdown.hasAttribute('open')) { apis.open(triggerElement); } }); }; if (this.isIOS_) { triggerElement.addEventListener('touchstart', triggerOpen); } else { triggerElement.addEventListener('click', triggerOpen); } } createDropdown_() { const dropdown = self.document.createElement('ljs-dropdown'); dropdown.setAttribute('layout', 'nodisplay'); if (this.blockSectionPosition_ === 'header') { dropdown.setAttribute('overlay-style', 'top: 4px;'); dropdown.setAttribute('placement', 'bottomRight'); } else if (this.blockSectionPosition_ === 'footer') { dropdown.setAttribute('overlay-style', 'top: -4px;'); dropdown.setAttribute('placement', 'top'); } return dropdown; } createDropdownIcon_() { const svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg"); svgElement.setAttribute("class", "market-rotate-180"); svgElement.setAttribute("width", "16"); svgElement.setAttribute("height", "16"); const path1 = document.createElementNS("http://www.w3.org/2000/svg", "path"); path1.setAttribute("d", "M7.47 5.172a.75.75 0 0 1 1.06 0l4.596 4.596a.75.75 0 1 1-1.06 1.06L7.468 6.232a.75.75 0 0 1 0-1.06Z"); path1.setAttribute("fill", "currentColor"); const path2 = document.createElementNS("http://www.w3.org/2000/svg", "path"); path2.setAttribute("d", "M8.533 5.172a.75.75 0 0 1 0 1.06l-4.596 4.596a.75.75 0 1 1-1.061-1.06l4.596-4.596a.75.75 0 0 1 1.06 0Z"); path2.setAttribute("fill", "currentColor"); svgElement.appendChild(path1); svgElement.appendChild(path2); return svgElement; } renderDropdownListWithClickEvent_({ triggerElement, dataList, subTitleRole, listElementWithTemplate, defaultValue, itemHandler, shouldUpdateSelectedItem = false, }) { const dropdown = this.createDropdown_(); const itemTemplate = SPZCore.Dom.scopedQuerySelector( listElementWithTemplate, 'template' ); const clonedItemTemplate = itemTemplate.cloneNode(true); const fragment = self.document.createDocumentFragment(); dataList.forEach((data) => { const tempParentNode = self.document.createElement('div'); const clonedTemplate = self.document.importNode( clonedItemTemplate.content, true ); tempParentNode.appendChild(clonedTemplate); tempParentNode.firstElementChild.classList.add( 'market-select-item' ); this.renderMarketSelectTemplateNode_(tempParentNode, data); const selectItemElement = SPZCore.Dom.scopedQuerySelector( tempParentNode, `[role="${MARKET_SELECT_ITEM}"]` ); if (!selectItemElement) { return; } if (defaultValue === data.value) { if (shouldUpdateSelectedItem) { const clonedSelectItemElement = selectItemElement.cloneNode(true); triggerElement.replaceChild( clonedSelectItemElement, triggerElement.firstElementChild ); } selectItemElement.setAttribute(PROPERTY_SELECTED, ''); } selectItemElement.setAttribute(MARKET_SELECT_ITEM_ID, data.value); fragment.appendChild(tempParentNode.firstElementChild); }); let value = defaultValue; listElementWithTemplate.addEventListener( 'click', (e) => { if (this.isEditMode) { this.showToast_('编辑器下不支持切换国家'); SPZ.whenApiDefined(dropdown).then((apis) => { apis.close(); }); return; } let targetElement = e.target; while (targetElement) { if ( !targetElement || targetElement.getAttribute(MARKET_SELECT_ITEM_ID) ) { break; } targetElement = targetElement.parentNode; } if ( !targetElement || !targetElement.hasAttribute(MARKET_SELECT_ITEM_ID) ) { return; } const selectValue = targetElement.getAttribute(MARKET_SELECT_ITEM_ID); if (value === selectValue) { SPZ.whenApiDefined(dropdown).then((apis) => { apis.close(); }); return; } const selectedData = dataList.find((c) => c.value === selectValue); if (shouldUpdateSelectedItem) { const tempParentNode = self.document.createElement('div'); const clonedTemplate = self.document.importNode( clonedItemTemplate.content, true ); tempParentNode.appendChild(clonedTemplate); this.renderMarketSelectTemplateNode_(tempParentNode, selectedData); tempParentNode.firstElementChild.classList.add( 'market-select-item' ); triggerElement.replaceChild( tempParentNode.firstElementChild, triggerElement.firstElementChild ); } value = selectValue; itemHandler?.(selectedData); SPZ.whenApiDefined(dropdown).then((apis) => { apis.close(); }); }, false ); listElementWithTemplate.removeChild(itemTemplate); listElementWithTemplate.appendChild(fragment); listElementWithTemplate.classList.add('market-select-list'); dropdown.appendChild(listElementWithTemplate); if (subTitleRole) { this.renderSelectTitle_(dropdown, subTitleRole); } return dropdown; } createSelect_({ parent, defaultValue, dataList, listElementWithTemplate, itemHandler, titleRole, }) { const triggerElement = self.document.createElement('div'); triggerElement.classList.add('market-select'); const displayElement = self.document.createElement('div'); triggerElement.appendChild(displayElement); triggerElement.appendChild(this.createDropdownIcon_()); const dropdown = this.renderDropdownListWithClickEvent_({ triggerElement, dataList, listElementWithTemplate, defaultValue, itemHandler, shouldUpdateSelectedItem: true, }); this.bindDropdownOpenClickEvent_(triggerElement, dropdown); const dropdownContainer = self.document.createElement('div'); dropdownContainer.appendChild(triggerElement); dropdownContainer.appendChild(dropdown); dropdownContainer.classList.add('market-select-container'); this.renderSelectTitle_(dropdownContainer, titleRole); parent.appendChild(dropdownContainer); } getListElementWithTemplate_(role) { const template = SPZCore.Dom.scopedQuerySelector( this.element, `[role="${role}"]` ); if (template) { const clonedTemplate = template.cloneNode(true); const tempParent = self.document.createElement("div"); tempParent.appendChild(clonedTemplate.content); const listElementWithTemplate = SPZCore.Dom.scopedQuerySelector( tempParent, `[role="${MARKET_SELECT_LIST}"]` ); return listElementWithTemplate; } return null; } renderSelectTitle_(parent, role) { if (!parent || !role) { return; } const template = SPZCore.Dom.scopedQuerySelector( this.element, `[role="${role}"]` ); const content = self.document.importNode(template.content, true); parent.insertBefore(content, parent.firstElementChild); parent.firstElementChild.classList.add( role.includes('sub') ? 'market-pc-header-select-sub-title' : 'market-pc-header-select-title' ); } initSelect_(rootNode, options) { const parent = rootNode || this.element; if (this.useCountrySelect_) { this.createSelect_({ parent, titleRole: options?.shouldRenderSelectTitle ? MARKET_PC_HEADER_COUNTRY_SELECT_TITLE : undefined, defaultValue: this.getDefaultCountryValue_(), dataList: this.marketCountryList.map(this.mapCountryRenderData_), listElementWithTemplate: this.getListElementWithTemplate_( MARKET_COUNTRY_SELECT ), itemHandler: this.handleCountrySelectChange_.bind(this), }); } if (this.useLanguageSelect_) { this.createSelect_({ parent, titleRole: options?.shouldRenderSelectTitle ? MARKET_PC_HEADER_LANGUAGE_SELECT_TITLE : undefined, defaultValue: this.getDefaultLanguageValue_(), dataList: this.marketLanguages.map(this.mapLanguageRenderData_), listElementWithTemplate: this.getListElementWithTemplate_( MARKET_LANGUAGE_SELECT ), itemHandler: this.handleLanguageSelectChange_.bind(this), }); } } initPcHeaderTriggerElement() { const headerTriggerElementTemplate = SPZCore.Dom.scopedQuerySelector( this.element, `[role="${MARKET_PC_HEADER_TRIGGER}"]` ); const headerTriggerElement = self.document.importNode( headerTriggerElementTemplate.content, true ); const parentDivElement = self.document.createElement('div'); parentDivElement.setAttribute('role', MARKET_PC_HEADER_TRIGGER); parentDivElement.appendChild(headerTriggerElement); this.element.removeChild(headerTriggerElementTemplate); return parentDivElement; } initPanelWithSelect_() { const triggerElement = this.initPcHeaderTriggerElement(); const dropdown = this.createDropdown_(); const panelElement = self.document.createElement('div'); panelElement.classList.add('market-panel'); this.initSelect_(panelElement, {shouldRenderSelectTitle: true}); dropdown.appendChild(panelElement); this.bindDropdownOpenClickEvent_(triggerElement, dropdown); this.element.appendChild(triggerElement); this.element.insertBefore(dropdown, triggerElement); } initSingleSelectDropdown_() { const triggerElement = this.initPcHeaderTriggerElement(); let dropdown; if (this.useCountrySelect_) { dropdown = this.renderDropdownListWithClickEvent_({ triggerElement, subTitleRole: MARKET_PC_HEADER_COUNTRY_SELECT_SUB_TITLE, dataList: this.marketCountryList.map(this.mapCountryRenderData_), listElementWithTemplate: this.getListElementWithTemplate_( MARKET_COUNTRY_SELECT ), defaultValue: this.getDefaultCountryValue_(), itemHandler: this.handleCountrySelectChange_.bind(this), }); } else if (this.useLanguageSelect_) { dropdown = this.renderDropdownListWithClickEvent_({ triggerElement, subTitleRole: MARKET_PC_HEADER_LANGUAGE_SELECT_SUB_TITLE, dataList: this.marketLanguages.map(this.mapLanguageRenderData_), listElementWithTemplate: this.getListElementWithTemplate_( MARKET_LANGUAGE_SELECT ), defaultValue: this.getDefaultLanguageValue_(), itemHandler: this.handleLanguageSelectChange_.bind(this), }); } if (dropdown) { this.bindDropdownOpenClickEvent_(triggerElement, dropdown); this.element.appendChild(triggerElement); this.element.appendChild(dropdown); } } initEntry_() { if (this.blockSectionPosition_ === SECTION_TYPE_HEADER) { if (this.isSingleSelectMode_) { this.initSingleSelectDropdown_(); } else if (this.useCountrySelect_ && this.useLanguageSelect_) { this.initPanelWithSelect_(); } } this.initSelect_(this.element); } async initData_() { const promises = []; if (this.useCountrySelect_ || this.useModal_) { promises.push(this.getCountryList_(), this.getIpMatchingMarket_()); } if (this.useLanguageSelect_) { promises.push(this.getMarketLanguages_(this.global.market.market_id)); } return Promise.all(promises).then((results) => { const ipMatchingMarket = results.find((result) => result.hasOwnProperty('matching_station') ); const marketCountryList = results.find((result) => result.hasOwnProperty('data') ); if (ipMatchingMarket && marketCountryList) { this.ipMatchingMarket = ipMatchingMarket?.matching_station?.find?.( (item) => item.type === 'multiple_market' ) || { img: marketCountryList.length ? marketCountryList?.[0]?.detail && marketCountryList[0].detail?.flag : '', }; } }); } initModal_() { if ( this.isEditMode || !this.ipMatchingMarket?.market_id || !this.useModal_ || this.hasCookie_(COOKIE_TIPS_NAME) || this.win[MARKET_MODAL_LOADED] ) { return; } this.win[MARKET_MODAL_LOADED] = true; const redirectParam = new URLSearchParams(this.win.location.search).get( URL_REDIRECT ); if (redirectParam) { this.initModalEntry_(MARKET_GATEWAY_REDIRECT_MODAL); } else if ( this.ipMatchingMarket.market_id !== this.global?.market?.market_id ) { this.initModalEntry_(MARKET_MODAL); } } async init_() { await this.initSettings_(); await this.initData_(); this.initEntry_(); this.initModal_(); } getDefaultCountryValue_() { return this.getCookie_(MARKET_COUNTRY_COOKIE) || this.marketCountryList[0]?.country_code; } mapCountryRenderData_(country) { return { flag: country?.detail?.flag || '', value: country?.country_code, currency: country?.currency, currencySymbol: country?.symbol?.val || '', url: country?.url, }; } handleCountrySelectChange_(selectedData) { this.setCookie_(MARKET_COUNTRY_COOKIE, selectedData.value); this.handleChangeURL_(selectedData.url); } getDefaultLanguageValue_() { return this.marketLanguages?.find?.( (lang) => lang.code === this.global?.market?.market_lang )?.name; } mapLanguageRenderData_(language) { return { value: language.name, url: language.url, }; } handleLanguageSelectChange_(selectedData) { this.handleChangeURL_(selectedData.url); } renderTemplateElement_(parent, role, value) { const elements = SPZCore.Dom.scopedQuerySelectorAll( parent, `[role="${role}"]` ); elements.forEach((element) => { if (element && value) { element.innerHTML = value; } }); } renderTemplateImg_(parent, role, options) { const flagElement = SPZCore.Dom.scopedQuerySelector( parent, `[role="${role}"]` ); if (flagElement && options?.src && options?.height && options?.width) { const spzImg = self.document.createElement('ljs-img'); spzImg.setAttribute('src', options.src); spzImg.setAttribute('layout', 'responsive'); spzImg.setAttribute('width', options.width); spzImg.setAttribute('height', options.height); spzImg.setAttribute( 'style', `width: ${options.width}px; height: ${options.height}px;` ); flagElement.appendChild(spzImg); } } handleChangeURL_(url) { if (!!url) { let {origin, pathname, search} = this.win.location; pathname = pathname.replace(SITE, url != '/' ? url : ''); this.win.location.href = `${origin}${pathname}${search}`; } else { this.win.location.reload(true); } } initModalEntry_(role) { const marketModalTemplate = SPZCore.Dom.scopedQuerySelector( this.element, `[role="${role}"]` ); if (marketModalTemplate) { const tempParentNode = self.document.createElement('div'); const clonedTemplate = self.document.importNode( marketModalTemplate.content, true ); tempParentNode.appendChild(clonedTemplate); this.renderTemplateImg_(tempParentNode, MARKET_MODAL_FLAG, { src: this.ipMatchingMarket?.img, width: '80', height: '80', }); this.renderTemplateElement_( tempParentNode, MARKET_MODAL_COUNTRY_CODE, this.ipMatchingMarket?.name ); this.renderTemplateElement_( tempParentNode, MARKET_MODAL_CURRENCY_SYMBOL, this.ipMatchingMarket?.currency_with_symbol ); const lightbox = self.document.createElement('ljs-lightbox'); lightbox.setAttribute('layout', 'nodisplay'); lightbox.appendChild(tempParentNode.firstElementChild); self.document.body.appendChild(lightbox); SPZ.whenApiDefined(lightbox).then((apis) => { SPZCore.Dom.scopedQuerySelectorAll( lightbox, `[role="${MARKET_MODAL_CLOSE}"]` ).forEach((ele) => { ele.addEventListener('click', () => { this.setCookie_(COOKIE_TIPS_NAME, 1, COOKIE_TIPS_EXPIRES); apis.close(); }); }); const marketModalConfirmElement = SPZCore.Dom.scopedQuerySelector( lightbox, `[role="${MARKET_MODAL_CONFIRM}"]` ); if (marketModalConfirmElement && this.ipMatchingMarket?.url) { marketModalConfirmElement.addEventListener('click', () => { this.setCookie_(COOKIE_TIPS_NAME, 1, COOKIE_TIPS_EXPIRES); this.setCookie_(MARKET_COUNTRY_COOKIE, this.ipMatchingMarket?.name); this.handleChangeURL_(this.ipMatchingMarket?.url); }); } const marketModalReselectElement = SPZCore.Dom.scopedQuerySelector( lightbox, `[role="${MARKET_MODAL_RESELECT}"]` ); if (marketModalReselectElement) { marketModalReselectElement.addEventListener('click', () => { this.setCookie_(COOKIE_TIPS_NAME, 1, COOKIE_TIPS_EXPIRES); const marketReselectTemplate = SPZCore.Dom.scopedQuerySelector( this.element, `[role="${MARKET_RESELECT_MODAL}"]` ); if (marketReselectTemplate && lightbox.firstElementChild) { const clonedTemplate = self.document.importNode( marketReselectTemplate.content, true ); const selectParent = SPZCore.Dom.scopedQuerySelector( clonedTemplate, `[role="${MARKET_MODAL_RESELECT_COUNTRY_SELECT}"]` ); if (selectParent) { this.createSelect_({ parent: selectParent, defaultValue: this.getDefaultCountryValue_(), dataList: this.marketCountryList.map( this.mapCountryRenderData_ ), listElementWithTemplate: this.getListElementWithTemplate_( MARKET_COUNTRY_SELECT ), itemHandler: this.handleCountrySelectChange_.bind(this), }); } lightbox.replaceChild(clonedTemplate, lightbox.firstElementChild); SPZCore.Dom.scopedQuerySelectorAll( lightbox, `[role="${MARKET_MODAL_CLOSE}"]` ).forEach((ele) => { ele.addEventListener('click', () => { this.setCookie_(COOKIE_TIPS_NAME, 1, COOKIE_TIPS_EXPIRES); apis.close(); }); }); } }); } apis.open(); }); } } async getMarketThemeSettings_() { return this.xhr_.fetchJson(MARKET_THEME_SETTINGS).then((res) => { this.useCountrySelect_ = !!res.country_selector_enabled; this.useLanguageSelect_ = !!res.language_selector_enabled && this.global?.market?.market_id; this.useModal_ = !!res.redirect_pop_enabled; return res; }); } async getCountryList_() { return this.xhr_.fetchJson(MARKET_COUNTRIES).then((res) => { this.marketCountryList = res.data.length ? res.data : []; return res; }); } async getIpMatchingMarket_() { return this.xhr_.fetchJson(IP_MATCHING_MARKET, { method: 'POST', body: { stations: [], }, }); } async getMarketLanguages_(marketId) { return this.xhr_ .fetchJson(MARKET_LANGUAGES.replace(/:id/gim, marketId)) .then((res) => { this.marketLanguages = res?.languages?.length ? res.languages : []; return res; }); } hasCookie_(name) { const m = self.document.cookie .split(';') .filter((pair) => pair.trim().startsWith(name + '=')); return !!(m && m[0]); } getCookie_(name) { const m = self.document.cookie .split(';') .filter((pair) => pair.trim().startsWith(name + '=')); return m && m[0] ? m[0].split('=')[1] : null; } setCookie_(name, value, expires) { const expiresDate = new Date(Date.now() + expires).toGMTString(); self.document.cookie = `${name}=${encodeURIComponent( value )};expires=${expiresDate};path=/`; } } SPZ.defineElement('spz-custom-market', SpzCustomMarket);
Region/Country
Region/Country
(
)
Language
Language
Switch to
based on your location
Purchase with
Get shipping options for
Set to
based on your location
Purchase with
Get shipping options for
Modify Country/Region
Log in
Create an account
${data.data && data.data.count}
${(function(){ if (data === undefined || typeof data !== 'string' || data == '') return '
'; const keyword = encodeURIComponent(data); return `
View more
Your search for '${data}' did not yield any results.
` })()}
${item}
Search
Recently searched
${item}
Hot searches
${item.word}
Results
${item.highlightHtml}
SHOP ALL
SHOP ALL
Tops
Tops
Short Sleeve Shirts
Cotton And Linen Shirts 🔥
Long Sleeve Shirts
Hoodies & Sweatshirts
Jackets & Coats 🔥
Long Sleeved T-Shirt
Polo Shirts👕
V-Neck Suit Vest/Tuxedo Waistcoat And Tie
100% Cotton Tees
Shirt with Breast Pocket
Bottoms
Bottoms
Men's Short Sets
Shorts
Pants
Customized Gift 🎁
Customized Gift 🎁
Holidays & Occasions
Short Sleeve Shirts
Sweatshirts
Tees
Baseball Caps
Accessories
Accessories
Socks
Belts & Suspenders
Shoes
Chic Matching Set
Dresses 👗
NEW
NEW
SHOP BY CATRGORY
SHOP BY CATRGORY
New in Short Sleeve Shirts
New in Hawaiian Shirts
New in Cotton And Linen Shirts
SHOP BY DATE
SHOP BY DATE
12/30/2024
12/23/2024
12/16/2024
12/02/2024
Best Seller
HOLIDAY & OCCASIONS 🥂
HOLIDAY & OCCASIONS 🥂
Mardi Gras Shirts 🎭
Valentine's Day Shirts 💕
St. Patrick's Day Shirts ☘
Cute Cartoon Shirts 🤠
Costume Ideas
Easter Day Shirts ✝️
Cinco De Mayo 💃
LGBT Pride Month 🏳️🌈
Happy Father's Day🎁
Hippie Shirts ☮
Patriots' Day Shirts
Oktoberfest🍺
Columbus Day ⚓
Veterans Day ✈️
Thanksgiving Day Tops 🦃
Halloween's Day Shirts 🎃🕸️
Christmas Eve Shirts 🎄
New Year Shirts 🎉
Short Sleeve Shirts
Short Sleeve Shirts
Shop By Category
Shop By Category
Short Sleeve Shirts
Cotton And Linen Shirts
Shirt with Breast Pocket
Tees
Polos
Tuxedo Waistcoat And Tie
Shop By Features
Shop By Features
Hot Sale 🔥
Customized 🎨
Funny Holiday
Costume Shirts🦸♂
70's Style 🎵
50‘s Style🔥
Fighter Series🛩️
Ukiyo-e 🌊
Sports 🏈
Music 🎸
Hippie Style
Hawaiian Shirts 🏄
Vintage Pin Up Girl Poster
Resort🏖️
Car 🏁🏎
Flag
BBQ
Shop By Pattern
Shop By Pattern
Cat 😸
Dog 🐕
Duck 🦆
Dragon 🐲
Gorilla 🦍
Flamingo 🦩
Shop By Pattern
Shop By Pattern
Leaves 🍃
Flowers 🌸
Octopus 🐙
Western Cowboy 🤠
Tattoo
Skull 💀
LONG SLEEVE TOPS
LONG SLEEVE TOPS
Long Sleeve Shirts
Hoodies & Sweatshirts
Jackets & Coats
Long Sleeve Polos
Long Sleeve T-Shirts
Personalized Customized 🎁
Personalized Customized 🎁
Holidays & Occasions
Short Sleeve Shirts
Tees
Sweatshirts
Baseball Caps
Flash Sale ⚡
Flash Sale ⚡
SHOP BY PRICE
SHOP BY PRICE
34% Off New Arrivals
Down to $9.9
Sales
Sales
Sale Shirts - Clearance
Sale Dresses - Clearance
Sale Waistcoat - Clearance
Sale Coats - Clearance
SURPRISE BOX 🎁
const marketSlot = document.querySelector(".plugin_c_market"); if(marketSlot) { marketSlot.remove(); }
const SITE = (window.C_SETTINGS || window[atob('U0hPUExBWlpB')])?.routes?.root || ''; const MARKET_THEME_SETTINGS = `${SITE}/api/markets/theme_setting`; const MARKET_COUNTRIES = `${SITE}/api/markets/countries`; const IP_MATCHING_MARKET = `${SITE}/api/front/station`; const MARKET_LANGUAGES = `${SITE}/api/markets/:id/active_languages`; const URL_REDIRECT = '_market_redirected'; const COOKIE_TIPS_NAME = 'market_no_tips'; const COOKIE_TIPS_EXPIRES = 1000 * 60 * 60 * 24 * 14; const MARKET_COUNTRY_COOKIE = '_shoplazza_market_country'; const MARKET_MODAL_LOADED = '__market_modal_loaded__'; const PROPERTY_SELECTED = 'selected'; const MARKET_PC_HEADER_TRIGGER = 'market-pc-header-trigger'; const MARKET_PC_HEADER_COUNTRY_SELECT_TITLE = 'market-pc-header-country-select-title'; const MARKET_PC_HEADER_LANGUAGE_SELECT_TITLE = 'market-pc-header-language-select-title'; const MARKET_PC_HEADER_LANGUAGE_SELECT_SUB_TITLE = 'market-pc-header-language-select-sub-title'; const MARKET_PC_HEADER_COUNTRY_SELECT_SUB_TITLE = 'market-pc-header-country-select-sub-title'; const MARKET_FLAG = 'market-flag'; const MARKET_SELECT_VALUE = 'market-select-value'; const MARKET_CURRENCY = 'market-currency'; const MARKET_CURRENCY_SYMBOL = 'market-currency-symbol'; const MARKET_SELECT_ITEM = 'market-select-item'; const MARKET_SELECT_ITEM_ID = 'market-select-item-id'; const MARKET_SELECT_LIST = 'market-select-list'; const MARKET_LANGUAGE_SELECT = 'market-language-select'; const MARKET_COUNTRY_SELECT = 'market-country-select'; const MARKET_MODAL = 'market-modal'; const MARKET_GATEWAY_REDIRECT_MODAL = 'market-gateway-redirect-modal'; const MARKET_RESELECT_MODAL = 'market-reselect-modal'; const MARKET_MODAL_FLAG = 'market-modal-flag'; const MARKET_MODAL_COUNTRY_CODE = 'market-modal-country-code'; const MARKET_MODAL_CURRENCY_SYMBOL = 'market-modal-currency-symbol'; const MARKET_MODAL_CLOSE = 'market-modal-close'; const MARKET_MODAL_CONFIRM = 'market-modal-confirm'; const MARKET_MODAL_RESELECT = 'market-modal-reselect'; const MARKET_MODAL_RESELECT_COUNTRY_SELECT = 'market-modal-reselect-country-select'; const DATA_SECTION_TYPE = 'data-section-type'; const SECTION_TYPE_HEADER = 'header'; const SECTION_TYPE_FOOTER = 'footer'; class SpzCustomMarket extends SPZ.BaseElement { constructor(element) { super(element); this.global = null; this.useCountrySelect_ = false; this.useLanguageSelect_ = false; this.useModal_ = false; this.isSingleSelectMode_ = false; this.blockSectionPosition_ = ''; this.isEditMode = false; this.ipMatchingMarket = null; this.marketCountryList = []; this.marketLanguages = []; this.toast = null; } static deferredMount() { return false; } isLayoutSupported(layout) { return layout == SPZCore.Layout.LOGIC; } buildCallback() { console.debug('Geolocation'); this.xhr_ = SPZServices.xhrFor(this.win); const platform = SPZServices.platformFor(this.win); this.isIOS_ = platform.isIos(); this.action_ = SPZServices.actionServiceForDoc(this.element); this.global = this.win.C_SETTINGS || this.win[atob('U0hPUExBWlpB')]; this.isEditMode = new URLSearchParams(this.win.location.search).get('preview_theme_id') && new URLSearchParams(this.win.location.search).get('oseid'); this.init_(); } showToast_(content) { if (!this.toast) { this.toast = self.document.createElement('ljs-toast'); this.toast.setAttribute('layout', 'nodisplay'); this.toast.setAttribute('hidden', ''); this.toast.setAttribute('duration', '2000'); this.element.appendChild(this.toast); } SPZ.whenApiDefined(this.toast).then((apis) => { apis.showToast(content); }); } triggerEvent_(name, data) { const event = SPZUtils.Event.create(this.win, `${TAG}.${name}`, data); this.action_.trigger(this.element, name, event); } findBlockSectionPosition() { let current = this.element; while (current) { const dataSectionType = current.getAttribute(DATA_SECTION_TYPE); if ( dataSectionType === SECTION_TYPE_HEADER || dataSectionType === SECTION_TYPE_FOOTER ) { return dataSectionType; } current = current.parentElement; } return ''; } async initSettings_() { await this.getMarketThemeSettings_(); if (this.useCountrySelect_) { this.element.setAttribute('use-country-select', true); } if (this.useLanguageSelect_) { this.element.setAttribute('use-language-select', true); } if (this.useModal_) { this.element.setAttribute('use-modal', true); } if ( (this.useCountrySelect_ && !this.useLanguageSelect_) || (!this.useCountrySelect_ && this.useLanguageSelect_) ) { this.isSingleSelectMode_ = true; } this.blockSectionPosition_ = this.findBlockSectionPosition(); this.isPCLayout_ = this.win.matchMedia('(min-width: 960px)').matches; } renderMarketSelectTemplateNode_(clonedTemplate, data) { this.renderTemplateImg_(clonedTemplate, MARKET_FLAG, { src: data?.flag, width: '24', height: '24', }); this.renderTemplateElement_( clonedTemplate, MARKET_SELECT_VALUE, data.value ); this.renderTemplateElement_( clonedTemplate, MARKET_CURRENCY, data?.currency ); this.renderTemplateElement_( clonedTemplate, MARKET_CURRENCY_SYMBOL, data?.currencySymbol ); } bindDropdownOpenClickEvent_(triggerElement, dropdown) { if (!triggerElement) return; const triggerOpen = () => { SPZ.whenApiDefined(dropdown).then((apis) => { if (!dropdown.hasAttribute('open')) { apis.open(triggerElement); } }); }; if (this.isIOS_) { triggerElement.addEventListener('touchstart', triggerOpen); } else { triggerElement.addEventListener('click', triggerOpen); } } createDropdown_() { const dropdown = self.document.createElement('ljs-dropdown'); dropdown.setAttribute('layout', 'nodisplay'); if (this.blockSectionPosition_ === 'header') { dropdown.setAttribute('overlay-style', 'top: 4px;'); dropdown.setAttribute('placement', 'bottomRight'); } else if (this.blockSectionPosition_ === 'footer') { dropdown.setAttribute('overlay-style', 'top: -4px;'); dropdown.setAttribute('placement', 'top'); } return dropdown; } createDropdownIcon_() { const svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg"); svgElement.setAttribute("class", "market-rotate-180"); svgElement.setAttribute("width", "16"); svgElement.setAttribute("height", "16"); const path1 = document.createElementNS("http://www.w3.org/2000/svg", "path"); path1.setAttribute("d", "M7.47 5.172a.75.75 0 0 1 1.06 0l4.596 4.596a.75.75 0 1 1-1.06 1.06L7.468 6.232a.75.75 0 0 1 0-1.06Z"); path1.setAttribute("fill", "currentColor"); const path2 = document.createElementNS("http://www.w3.org/2000/svg", "path"); path2.setAttribute("d", "M8.533 5.172a.75.75 0 0 1 0 1.06l-4.596 4.596a.75.75 0 1 1-1.061-1.06l4.596-4.596a.75.75 0 0 1 1.06 0Z"); path2.setAttribute("fill", "currentColor"); svgElement.appendChild(path1); svgElement.appendChild(path2); return svgElement; } renderDropdownListWithClickEvent_({ triggerElement, dataList, subTitleRole, listElementWithTemplate, defaultValue, itemHandler, shouldUpdateSelectedItem = false, }) { const dropdown = this.createDropdown_(); const itemTemplate = SPZCore.Dom.scopedQuerySelector( listElementWithTemplate, 'template' ); const clonedItemTemplate = itemTemplate.cloneNode(true); const fragment = self.document.createDocumentFragment(); dataList.forEach((data) => { const tempParentNode = self.document.createElement('div'); const clonedTemplate = self.document.importNode( clonedItemTemplate.content, true ); tempParentNode.appendChild(clonedTemplate); tempParentNode.firstElementChild.classList.add( 'market-select-item' ); this.renderMarketSelectTemplateNode_(tempParentNode, data); const selectItemElement = SPZCore.Dom.scopedQuerySelector( tempParentNode, `[role="${MARKET_SELECT_ITEM}"]` ); if (!selectItemElement) { return; } if (defaultValue === data.value) { if (shouldUpdateSelectedItem) { const clonedSelectItemElement = selectItemElement.cloneNode(true); triggerElement.replaceChild( clonedSelectItemElement, triggerElement.firstElementChild ); } selectItemElement.setAttribute(PROPERTY_SELECTED, ''); } selectItemElement.setAttribute(MARKET_SELECT_ITEM_ID, data.value); fragment.appendChild(tempParentNode.firstElementChild); }); let value = defaultValue; listElementWithTemplate.addEventListener( 'click', (e) => { if (this.isEditMode) { this.showToast_('编辑器下不支持切换国家'); SPZ.whenApiDefined(dropdown).then((apis) => { apis.close(); }); return; } let targetElement = e.target; while (targetElement) { if ( !targetElement || targetElement.getAttribute(MARKET_SELECT_ITEM_ID) ) { break; } targetElement = targetElement.parentNode; } if ( !targetElement || !targetElement.hasAttribute(MARKET_SELECT_ITEM_ID) ) { return; } const selectValue = targetElement.getAttribute(MARKET_SELECT_ITEM_ID); if (value === selectValue) { SPZ.whenApiDefined(dropdown).then((apis) => { apis.close(); }); return; } const selectedData = dataList.find((c) => c.value === selectValue); if (shouldUpdateSelectedItem) { const tempParentNode = self.document.createElement('div'); const clonedTemplate = self.document.importNode( clonedItemTemplate.content, true ); tempParentNode.appendChild(clonedTemplate); this.renderMarketSelectTemplateNode_(tempParentNode, selectedData); tempParentNode.firstElementChild.classList.add( 'market-select-item' ); triggerElement.replaceChild( tempParentNode.firstElementChild, triggerElement.firstElementChild ); } value = selectValue; itemHandler?.(selectedData); SPZ.whenApiDefined(dropdown).then((apis) => { apis.close(); }); }, false ); listElementWithTemplate.removeChild(itemTemplate); listElementWithTemplate.appendChild(fragment); listElementWithTemplate.classList.add('market-select-list'); dropdown.appendChild(listElementWithTemplate); if (subTitleRole) { this.renderSelectTitle_(dropdown, subTitleRole); } return dropdown; } createSelect_({ parent, defaultValue, dataList, listElementWithTemplate, itemHandler, titleRole, }) { const triggerElement = self.document.createElement('div'); triggerElement.classList.add('market-select'); const displayElement = self.document.createElement('div'); triggerElement.appendChild(displayElement); triggerElement.appendChild(this.createDropdownIcon_()); const dropdown = this.renderDropdownListWithClickEvent_({ triggerElement, dataList, listElementWithTemplate, defaultValue, itemHandler, shouldUpdateSelectedItem: true, }); this.bindDropdownOpenClickEvent_(triggerElement, dropdown); const dropdownContainer = self.document.createElement('div'); dropdownContainer.appendChild(triggerElement); dropdownContainer.appendChild(dropdown); dropdownContainer.classList.add('market-select-container'); this.renderSelectTitle_(dropdownContainer, titleRole); parent.appendChild(dropdownContainer); } getListElementWithTemplate_(role) { const template = SPZCore.Dom.scopedQuerySelector( this.element, `[role="${role}"]` ); if (template) { const clonedTemplate = template.cloneNode(true); const tempParent = self.document.createElement("div"); tempParent.appendChild(clonedTemplate.content); const listElementWithTemplate = SPZCore.Dom.scopedQuerySelector( tempParent, `[role="${MARKET_SELECT_LIST}"]` ); return listElementWithTemplate; } return null; } renderSelectTitle_(parent, role) { if (!parent || !role) { return; } const template = SPZCore.Dom.scopedQuerySelector( this.element, `[role="${role}"]` ); const content = self.document.importNode(template.content, true); parent.insertBefore(content, parent.firstElementChild); parent.firstElementChild.classList.add( role.includes('sub') ? 'market-pc-header-select-sub-title' : 'market-pc-header-select-title' ); } initSelect_(rootNode, options) { const parent = rootNode || this.element; if (this.useCountrySelect_) { this.createSelect_({ parent, titleRole: options?.shouldRenderSelectTitle ? MARKET_PC_HEADER_COUNTRY_SELECT_TITLE : undefined, defaultValue: this.getDefaultCountryValue_(), dataList: this.marketCountryList.map(this.mapCountryRenderData_), listElementWithTemplate: this.getListElementWithTemplate_( MARKET_COUNTRY_SELECT ), itemHandler: this.handleCountrySelectChange_.bind(this), }); } if (this.useLanguageSelect_) { this.createSelect_({ parent, titleRole: options?.shouldRenderSelectTitle ? MARKET_PC_HEADER_LANGUAGE_SELECT_TITLE : undefined, defaultValue: this.getDefaultLanguageValue_(), dataList: this.marketLanguages.map(this.mapLanguageRenderData_), listElementWithTemplate: this.getListElementWithTemplate_( MARKET_LANGUAGE_SELECT ), itemHandler: this.handleLanguageSelectChange_.bind(this), }); } } initPcHeaderTriggerElement() { const headerTriggerElementTemplate = SPZCore.Dom.scopedQuerySelector( this.element, `[role="${MARKET_PC_HEADER_TRIGGER}"]` ); const headerTriggerElement = self.document.importNode( headerTriggerElementTemplate.content, true ); const parentDivElement = self.document.createElement('div'); parentDivElement.setAttribute('role', MARKET_PC_HEADER_TRIGGER); parentDivElement.appendChild(headerTriggerElement); this.element.removeChild(headerTriggerElementTemplate); return parentDivElement; } initPanelWithSelect_() { const triggerElement = this.initPcHeaderTriggerElement(); const dropdown = this.createDropdown_(); const panelElement = self.document.createElement('div'); panelElement.classList.add('market-panel'); this.initSelect_(panelElement, {shouldRenderSelectTitle: true}); dropdown.appendChild(panelElement); this.bindDropdownOpenClickEvent_(triggerElement, dropdown); this.element.appendChild(triggerElement); this.element.insertBefore(dropdown, triggerElement); } initSingleSelectDropdown_() { const triggerElement = this.initPcHeaderTriggerElement(); let dropdown; if (this.useCountrySelect_) { dropdown = this.renderDropdownListWithClickEvent_({ triggerElement, subTitleRole: MARKET_PC_HEADER_COUNTRY_SELECT_SUB_TITLE, dataList: this.marketCountryList.map(this.mapCountryRenderData_), listElementWithTemplate: this.getListElementWithTemplate_( MARKET_COUNTRY_SELECT ), defaultValue: this.getDefaultCountryValue_(), itemHandler: this.handleCountrySelectChange_.bind(this), }); } else if (this.useLanguageSelect_) { dropdown = this.renderDropdownListWithClickEvent_({ triggerElement, subTitleRole: MARKET_PC_HEADER_LANGUAGE_SELECT_SUB_TITLE, dataList: this.marketLanguages.map(this.mapLanguageRenderData_), listElementWithTemplate: this.getListElementWithTemplate_( MARKET_LANGUAGE_SELECT ), defaultValue: this.getDefaultLanguageValue_(), itemHandler: this.handleLanguageSelectChange_.bind(this), }); } if (dropdown) { this.bindDropdownOpenClickEvent_(triggerElement, dropdown); this.element.appendChild(triggerElement); this.element.appendChild(dropdown); } } initEntry_() { if (this.blockSectionPosition_ === SECTION_TYPE_HEADER) { if (this.isSingleSelectMode_) { this.initSingleSelectDropdown_(); } else if (this.useCountrySelect_ && this.useLanguageSelect_) { this.initPanelWithSelect_(); } } this.initSelect_(this.element); } async initData_() { const promises = []; if (this.useCountrySelect_ || this.useModal_) { promises.push(this.getCountryList_(), this.getIpMatchingMarket_()); } if (this.useLanguageSelect_) { promises.push(this.getMarketLanguages_(this.global.market.market_id)); } return Promise.all(promises).then((results) => { const ipMatchingMarket = results.find((result) => result.hasOwnProperty('matching_station') ); const marketCountryList = results.find((result) => result.hasOwnProperty('data') ); if (ipMatchingMarket && marketCountryList) { this.ipMatchingMarket = ipMatchingMarket?.matching_station?.find?.( (item) => item.type === 'multiple_market' ) || { img: marketCountryList.length ? marketCountryList?.[0]?.detail && marketCountryList[0].detail?.flag : '', }; } }); } initModal_() { if ( this.isEditMode || !this.ipMatchingMarket?.market_id || !this.useModal_ || this.hasCookie_(COOKIE_TIPS_NAME) || this.win[MARKET_MODAL_LOADED] ) { return; } this.win[MARKET_MODAL_LOADED] = true; const redirectParam = new URLSearchParams(this.win.location.search).get( URL_REDIRECT ); if (redirectParam) { this.initModalEntry_(MARKET_GATEWAY_REDIRECT_MODAL); } else if ( this.ipMatchingMarket.market_id !== this.global?.market?.market_id ) { this.initModalEntry_(MARKET_MODAL); } } async init_() { await this.initSettings_(); await this.initData_(); this.initEntry_(); this.initModal_(); } getDefaultCountryValue_() { return this.getCookie_(MARKET_COUNTRY_COOKIE) || this.marketCountryList[0]?.country_code; } mapCountryRenderData_(country) { return { flag: country?.detail?.flag || '', value: country?.country_code, currency: country?.currency, currencySymbol: country?.symbol?.val || '', url: country?.url, }; } handleCountrySelectChange_(selectedData) { this.setCookie_(MARKET_COUNTRY_COOKIE, selectedData.value); this.handleChangeURL_(selectedData.url); } getDefaultLanguageValue_() { return this.marketLanguages?.find?.( (lang) => lang.code === this.global?.market?.market_lang )?.name; } mapLanguageRenderData_(language) { return { value: language.name, url: language.url, }; } handleLanguageSelectChange_(selectedData) { this.handleChangeURL_(selectedData.url); } renderTemplateElement_(parent, role, value) { const elements = SPZCore.Dom.scopedQuerySelectorAll( parent, `[role="${role}"]` ); elements.forEach((element) => { if (element && value) { element.innerHTML = value; } }); } renderTemplateImg_(parent, role, options) { const flagElement = SPZCore.Dom.scopedQuerySelector( parent, `[role="${role}"]` ); if (flagElement && options?.src && options?.height && options?.width) { const spzImg = self.document.createElement('ljs-img'); spzImg.setAttribute('src', options.src); spzImg.setAttribute('layout', 'responsive'); spzImg.setAttribute('width', options.width); spzImg.setAttribute('height', options.height); spzImg.setAttribute( 'style', `width: ${options.width}px; height: ${options.height}px;` ); flagElement.appendChild(spzImg); } } handleChangeURL_(url) { if (!!url) { let {origin, pathname, search} = this.win.location; pathname = pathname.replace(SITE, url != '/' ? url : ''); this.win.location.href = `${origin}${pathname}${search}`; } else { this.win.location.reload(true); } } initModalEntry_(role) { const marketModalTemplate = SPZCore.Dom.scopedQuerySelector( this.element, `[role="${role}"]` ); if (marketModalTemplate) { const tempParentNode = self.document.createElement('div'); const clonedTemplate = self.document.importNode( marketModalTemplate.content, true ); tempParentNode.appendChild(clonedTemplate); this.renderTemplateImg_(tempParentNode, MARKET_MODAL_FLAG, { src: this.ipMatchingMarket?.img, width: '80', height: '80', }); this.renderTemplateElement_( tempParentNode, MARKET_MODAL_COUNTRY_CODE, this.ipMatchingMarket?.name ); this.renderTemplateElement_( tempParentNode, MARKET_MODAL_CURRENCY_SYMBOL, this.ipMatchingMarket?.currency_with_symbol ); const lightbox = self.document.createElement('ljs-lightbox'); lightbox.setAttribute('layout', 'nodisplay'); lightbox.appendChild(tempParentNode.firstElementChild); self.document.body.appendChild(lightbox); SPZ.whenApiDefined(lightbox).then((apis) => { SPZCore.Dom.scopedQuerySelectorAll( lightbox, `[role="${MARKET_MODAL_CLOSE}"]` ).forEach((ele) => { ele.addEventListener('click', () => { this.setCookie_(COOKIE_TIPS_NAME, 1, COOKIE_TIPS_EXPIRES); apis.close(); }); }); const marketModalConfirmElement = SPZCore.Dom.scopedQuerySelector( lightbox, `[role="${MARKET_MODAL_CONFIRM}"]` ); if (marketModalConfirmElement && this.ipMatchingMarket?.url) { marketModalConfirmElement.addEventListener('click', () => { this.setCookie_(COOKIE_TIPS_NAME, 1, COOKIE_TIPS_EXPIRES); this.setCookie_(MARKET_COUNTRY_COOKIE, this.ipMatchingMarket?.name); this.handleChangeURL_(this.ipMatchingMarket?.url); }); } const marketModalReselectElement = SPZCore.Dom.scopedQuerySelector( lightbox, `[role="${MARKET_MODAL_RESELECT}"]` ); if (marketModalReselectElement) { marketModalReselectElement.addEventListener('click', () => { this.setCookie_(COOKIE_TIPS_NAME, 1, COOKIE_TIPS_EXPIRES); const marketReselectTemplate = SPZCore.Dom.scopedQuerySelector( this.element, `[role="${MARKET_RESELECT_MODAL}"]` ); if (marketReselectTemplate && lightbox.firstElementChild) { const clonedTemplate = self.document.importNode( marketReselectTemplate.content, true ); const selectParent = SPZCore.Dom.scopedQuerySelector( clonedTemplate, `[role="${MARKET_MODAL_RESELECT_COUNTRY_SELECT}"]` ); if (selectParent) { this.createSelect_({ parent: selectParent, defaultValue: this.getDefaultCountryValue_(), dataList: this.marketCountryList.map( this.mapCountryRenderData_ ), listElementWithTemplate: this.getListElementWithTemplate_( MARKET_COUNTRY_SELECT ), itemHandler: this.handleCountrySelectChange_.bind(this), }); } lightbox.replaceChild(clonedTemplate, lightbox.firstElementChild); SPZCore.Dom.scopedQuerySelectorAll( lightbox, `[role="${MARKET_MODAL_CLOSE}"]` ).forEach((ele) => { ele.addEventListener('click', () => { this.setCookie_(COOKIE_TIPS_NAME, 1, COOKIE_TIPS_EXPIRES); apis.close(); }); }); } }); } apis.open(); }); } } async getMarketThemeSettings_() { return this.xhr_.fetchJson(MARKET_THEME_SETTINGS).then((res) => { this.useCountrySelect_ = !!res.country_selector_enabled; this.useLanguageSelect_ = !!res.language_selector_enabled && this.global?.market?.market_id; this.useModal_ = !!res.redirect_pop_enabled; return res; }); } async getCountryList_() { return this.xhr_.fetchJson(MARKET_COUNTRIES).then((res) => { this.marketCountryList = res.data.length ? res.data : []; return res; }); } async getIpMatchingMarket_() { return this.xhr_.fetchJson(IP_MATCHING_MARKET, { method: 'POST', body: { stations: [], }, }); } async getMarketLanguages_(marketId) { return this.xhr_ .fetchJson(MARKET_LANGUAGES.replace(/:id/gim, marketId)) .then((res) => { this.marketLanguages = res?.languages?.length ? res.languages : []; return res; }); } hasCookie_(name) { const m = self.document.cookie .split(';') .filter((pair) => pair.trim().startsWith(name + '=')); return !!(m && m[0]); } getCookie_(name) { const m = self.document.cookie .split(';') .filter((pair) => pair.trim().startsWith(name + '=')); return m && m[0] ? m[0].split('=')[1] : null; } setCookie_(name, value, expires) { const expiresDate = new Date(Date.now() + expires).toGMTString(); self.document.cookie = `${name}=${encodeURIComponent( value )};expires=${expiresDate};path=/`; } } SPZ.defineElement('spz-custom-market', SpzCustomMarket);
Region/Country
Region/Country
(
)
Language
Language
Switch to
based on your location
Purchase with
Get shipping options for
Set to
based on your location
Purchase with
Get shipping options for
Modify Country/Region
Log in
Create an account
(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(); })();
Home
/
HOO® Black, Gray and Brown Color Matching Turndown Collar Button Down Men's Short Sleeve Shirt
1/3
${data.index + 1}/${data.total}
${Array(data.total).fill(0).map((num, index) => `
`).join('')}
New Year's Sale 🎇
HOO® Black, Gray and Brown Color Matching Turndown Collar Button Down Men's Short Sleeve Shirt
$9.95
$30.00
${function() { const variantData = data.variant || {"id":"bd984648-eeaa-46f8-8798-21a11ae80f30","product_id":"6306c261-7214-4f0d-a46c-8868bade0c96","title":"Black-L","weight_unit":"g","inventory_quantity":1,"sku":"BTWL21072112H-L","barcode":"BTWL21072112H","position":1,"option1":"Black","option2":"L","option3":"","note":"","image":{"src":"\/\/img.staticdj.com\/5f19a4f57b01a9322fd94cc550225044.jpeg","path":"5f19a4f57b01a9322fd94cc550225044.jpeg","width":750,"height":1000,"alt":"","aspect_ratio":0.75},"wholesale_price":[{"price":9.95,"min_quantity":1}],"weight":"200","compare_at_price":"30","price":"9.95","retail_price":"30","available":true,"url":"\/products\/black-dark-green-and-brown-color-matching-turndown-collar-button-down-mens-short-sleeve-shirt-1?variant=bd984648-eeaa-46f8-8798-21a11ae80f30","available_quantity":1,"options":[{"name":"Color","value":"Black"},{"name":"Size","value":"L"}],"off_ratio":67,"flashsale_info":[],"sales":2}; const saveType = "amount"; const productLabelDiscountOn = false; return `
-
${saveType == 'percentage' ? `
-${variantData.off_ratio}%
` : `
-
` }
`; }()}
Color:
Black
${function(){ const optName = "Color"; const optionValue = data.originData.selectData ? data.originData.selectData[optName].value : data.originData.value; const optionValueText = optionValue ? (optionValue) : ''; return `
${optionValueText}
`; }()}
${function(){ const tipText = "Please select a {{ name }}".replace(/\{\{\s+name\s+\}\}/g, data); return `
${tipText}
` }()}
Size:
L
${function(){ const optName = "Size"; const optionValue = data.originData.selectData ? data.originData.selectData[optName].value : data.originData.value; const optionValueText = optionValue ? (optionValue) : ''; return `
${optionValueText}
`; }()}
L
2XL
3XL
${function(){ const tipText = "Please select a {{ name }}".replace(/\{\{\s+name\s+\}\}/g, data); return `
${tipText}
` }()}
Quantity