Loppuunmyytyjen versioiden piilottaminen
Tämä sivu on tulostettu Apr 19, 2024. Nykyinen versio on osoitteessa https://help.shopify.com/fi/manual/online-store/themes/themes-by-shopify/vintage-themes/customizing-vintage-themes/hide-sold-out-variants.
Huomio
Vanhoja teemoja ei ole saatavilla Theme Storessa. Näissä teemoissa ei ole Shopifyn Online Store 2.0 -teemoihin sisältyviä ominaisuuksia, eikä niihin tehdä muita päivityksiä kuin turvallisuuskorjauksia.
Huomaa
Jos käytät Shopifyn ilmaista teemaa , voit ottaa yhteyttä Shopify-tukeen tutoriaaliin liittyvissä asioissa. Tähän tarvitaan 15 minuuttia suunnitteluaikaa. Lisätietoja on kohdassa Teemojen tuki .
Huomaa
tämä mukautus koskee vain vanhoja Shopify-teemoja, eikä sitä sovelleta Online Store 2.0 -teemoihin.
Voit estää asiakkaita valitsemasta loppuunmyytyjä versioita poistamalla nämä versiot käytöstä tai kokonaan tuotesivulta.
Rajoitukset Tällä sivulla kuvatut mukautukset eivät toimi seuraavissa tapauksissa:
Tuotteillasi on useampi kuin yksi tuotevaihtoehto
Käytät Express -teemaa, ja tuotesivu on asetettu näyttämään tuotteet peittokuvana
Osiin jaetut ja jakamattomat teemat
Huomautus: Tämän tutoriaalin vaiheet vaihtelevat sen mukaan, käytätkö osiin jaettua vai osiin jakamatonta teemaa. Osiin jaetussa teemassa etusivun asettelua voi järjestää vetämällä ja pudottamalla elementtejä, osiin jakamattomassa teemassa ei.
Teeman Muokkaa koodia -sivulla saat selville tukeeko teemasi osioita. Jos Osiot -hakemistossa on tiedostoja, käytössäsi on osioihin jaettu teema. Osioihin jakamattomat teemat on julkaistu ennen lokakuuta 2016, eikä niiden Osiot -hakemistossa ole tiedostoja.
Jos käytät osioihin jaettua teemaa, klikkaa Osioihin jaetut teemat -painiketta ja noudata ohjeita. Jos käytät vanhempaa teemaa, jota ei ole jaettu osioihin, klikkaa Osioihin jakamattomat teemat -painiketta ja noudata ohjeita.
Osiin jaettujen teemojen ohjeet Valitse teema Tämän mukautuksen toimintavaiheet vaihtelevat teeman mukaan. Klikkaa teeman painiketta ennen kuin noudatat seuraavia ohjeita:
Boundless
Tämän mukautuksen työvaiheet vaihtelevat sen mukaan, haluatko piilottaa loppuunmyyty-versiot kokonaan vai poistaa ne käytöstä.
Loppuunmyytyjen versioiden piilottaminen
Siirry Shopify Adminissa kohtaan Verkkosivu > Teemat .
Etsi teema, jota haluat muokata, avaa toimintovalikko klikkaamalla ... -painiketta ja klikkaa sitten Muokkaa koodia .
klikkaa Sisällöt -hakemistossa valintaa theme.js
tai theme.js.liquid
.
Liitä tiedoston loppuun seuraava koodi:
document . addEventListener ( ' DOMContentLoaded ' , function () {
const productJson = document . querySelectorAll ( ' [id^=ProductJson- ' );
if ( productJson . length > 0 ) {
for ( let i = 0 ; i < productJson . length ; i ++ ) {
const current = productJson [ i ];
const sectionId = current . id . replace ( ' ProductJson- ' , '' );
const section = document . querySelector ( ' [data-section-id=" ' + sectionId + ' "] ' );
const product = JSON . parse ( current . text );
if ( product . options . length === 1 ) {
const unavailableVariants = [];
for ( let j = 0 ; j < product . variants . length ; j ++ ) {
const variant = product . variants [ j ];
if ( ! variant . available ) {
unavailableVariants . push ( variant );
}
}
if ( unavailableVariants . length > 0 ) {
const mutationCallback = function () {
const variantOptions = section . querySelectorAll ( ' .single-option-selector option ' );
if ( variantOptions . length > 0 ) {
for ( let k = 0 ; k < unavailableVariants . length ; k ++ ) {
const unavailableVariant = unavailableVariants [ k ];
for ( let l = 0 ; l < variantOptions . length ; l ++ ) {
const option = variantOptions [ l ];
if ( unavailableVariant . title === option . value ) {
option . remove ();
}
}
}
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
}
}
const observer = new MutationObserver ( mutationCallback );
const addToCartForm = document . querySelector ( ' form[action*="/cart/add"] ' );
mutationCallback ();
if ( window . MutationObserver && addToCartForm . length ) {
const config = { childList : true , subtree : true };
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
observer . observe ( addToCartForm , config );
}
}
}
}
}
});
Klikkaa Tallenna .
Loppuunmyytyjen versioiden poistaminen käytöstä
Siirry Shopify Adminissa kohtaan Verkkosivu > Teemat .
Etsi teema, jota haluat muokata, avaa toimintovalikko klikkaamalla ... -painiketta ja klikkaa sitten Muokkaa koodia .
klikkaa Sisällöt -hakemistossa valintaa theme.js
tai theme.js.liquid
.
Liitä tiedoston loppuun seuraava koodi:
document . addEventListener ( ' DOMContentLoaded ' , function () {
const productJson = document . querySelectorAll ( ' [id^=ProductJson- ' );
if ( productJson . length > 0 ) {
for ( let i = 0 ; i < productJson . length ; i ++ ) {
const current = productJson [ i ];
const sectionId = current . id . replace ( ' ProductJson- ' , '' );
const section = document . querySelector ( ' [data-section-id=" ' + sectionId + ' "] ' );
const product = JSON . parse ( current . text );
if ( product . options . length === 1 ) {
const unavailableVariants = [];
for ( let j = 0 ; j < product . variants . length ; j ++ ) {
const variant = product . variants [ j ];
if ( ! variant . available ) {
unavailableVariants . push ( variant );
}
}
if ( unavailableVariants . length > 0 ) {
const mutationCallback = function () {
const variantOptions = section . querySelectorAll ( ' .single-option-selector option ' );
if ( variantOptions . length > 0 ) {
for ( let k = 0 ; k < unavailableVariants . length ; k ++ ) {
const unavailableVariant = unavailableVariants [ k ];
for ( let l = 0 ; l < variantOptions . length ; l ++ ) {
const option = variantOptions [ l ];
if ( unavailableVariant . title === option . value ) {
option . setAttribute ( ' disabled ' , ' disabled ' );
}
}
}
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
}
}
const observer = new MutationObserver ( mutationCallback );
const addToCartForm = document . querySelector ( ' form[action*="/cart/add"] ' );
mutationCallback ();
if ( window . MutationObserver && addToCartForm . length ) {
const config = { childList : true , subtree : true };
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
observer . observe ( addToCartForm , config );
}
}
}
}
}
});
Klikkaa Tallenna .
Brooklyn
Tämän mukautuksen työvaiheet vaihtelevat sen mukaan, haluatko piilottaa loppuunmyyty-versiot kokonaan vai poistaa ne käytöstä.
Loppuunmyytyjen versioiden piilottaminen
Siirry Shopify Adminissa kohtaan Verkkosivu > Teemat .
Etsi teema, jota haluat muokata, avaa toimintovalikko klikkaamalla ... -painiketta ja klikkaa sitten Muokkaa koodia .
klikkaa Sisällöt -hakemistossa valintaa theme.js
tai theme.js.liquid
.
Liitä tiedoston loppuun seuraava koodi:
document . addEventListener ( ' DOMContentLoaded ' , function () {
const productJson = document . querySelectorAll ( ' [id^=ProductJson- ' );
if ( productJson . length > 0 ) {
for ( let i = 0 ; i < productJson . length ; i ++ ) {
const current = productJson [ i ];
const sectionId = current . id . replace ( ' ProductJson- ' , '' );
const section = document . querySelector ( ' [data-section-id=" ' + sectionId + ' "] ' );
const product = JSON . parse ( current . text );
if ( product . options . length === 1 ) {
const unavailableVariants = [];
for ( let j = 0 ; j < product . variants . length ; j ++ ) {
const variant = product . variants [ j ];
if ( ! variant . available ) {
unavailableVariants . push ( variant );
}
}
if ( unavailableVariants . length > 0 ) {
const mutationCallback = function () {
const radioButtons = section . querySelector ( ' .single-option-radio ' );
let variantOptions ;
if ( radioButtons ) {
variantOptions = section . querySelectorAll ( ' .single-option-radio input ' );
} else {
variantOptions = section . querySelectorAll ( ' .single-option-selector__radio option ' );
}
if ( variantOptions . length > 0 ) {
for ( let k = 0 ; k < unavailableVariants . length ; k ++ ) {
const unavailableVariant = unavailableVariants [ k ];
for ( let l = 0 ; l < variantOptions . length ; l ++ ) {
const option = variantOptions [ l ];
if ( unavailableVariant . title === option . value ) {
if ( radioButtons ) {
option . nextElementSibling . remove ();
}
option . remove ();
}
}
}
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
}
}
const observer = new MutationObserver ( mutationCallback );
const addToCartForm = document . querySelector ( ' form[action*="/cart/add"] ' );
mutationCallback ();
if ( window . MutationObserver && addToCartForm . length ) {
const config = { childList : true , subtree : true };
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
observer . observe ( addToCartForm , config );
}
}
}
}
}
});
Klikkaa Tallenna .
Loppuunmyytyjen versioiden poistaminen käytöstä
Siirry Shopify Adminissa kohtaan Verkkosivu > Teemat .
Etsi teema, jota haluat muokata, avaa toimintovalikko klikkaamalla ... -painiketta ja klikkaa sitten Muokkaa koodia .
klikkaa Sisällöt -hakemistossa valintaa theme.js
tai theme.js.liquid
.
Liitä tiedoston loppuun seuraava koodi:
document . addEventListener ( ' DOMContentLoaded ' , function () {
const productJson = document . querySelectorAll ( ' [id^=ProductJson- ' );
if ( productJson . length > 0 ) {
for ( let i = 0 ; i < productJson . length ; i ++ ) {
const current = productJson [ i ];
const sectionId = current . id . replace ( ' ProductJson- ' , '' );
const section = document . querySelector ( ' [data-section-id=" ' + sectionId + ' "] ' );
const product = JSON . parse ( current . text );
if ( product . options . length === 1 ) {
const unavailableVariants = [];
for ( let j = 0 ; j < product . variants . length ; j ++ ) {
const variant = product . variants [ j ];
if ( ! variant . available ) {
unavailableVariants . push ( variant );
}
}
if ( unavailableVariants . length > 0 ) {
const mutationCallback = function () {
const radioButtons = section . querySelector ( ' .single-option-radio ' );
let variantOptions ;
if ( radioButtons ) {
variantOptions = section . querySelectorAll ( ' .single-option-radio input ' );
} else {
variantOptions = section . querySelectorAll ( ' .single-option-selector__radio option ' );
}
if ( variantOptions . length > 0 ) {
for ( let k = 0 ; k < unavailableVariants . length ; k ++ ) {
const unavailableVariant = unavailableVariants [ k ];
for ( let l = 0 ; l < variantOptions . length ; l ++ ) {
const option = variantOptions [ l ];
if ( unavailableVariant . title === option . value ) {
if ( radioButtons ) {
option . nextElementSibling . option . setAttribute ( ' disabled ' , ' disabled ' );
}
option . setAttribute ( ' disabled ' , ' disabled ' );
}
}
}
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
}
}
const observer = new MutationObserver ( mutationCallback );
const addToCartForm = document . querySelector ( ' form[action*="/cart/add"] ' );
mutationCallback ();
if ( window . MutationObserver && addToCartForm . length ) {
const config = { childList : true , subtree : true };
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
observer . observe ( addToCartForm , config );
}
}
}
}
}
});
Klikkaa Tallenna .
Debut
Tämän mukautuksen työvaiheet vaihtelevat sen mukaan, haluatko piilottaa loppuunmyyty-versiot kokonaan vai poistaa ne käytöstä.
Loppuunmyytyjen versioiden piilottaminen
Siirry Shopify Adminissa kohtaan Verkkosivu > Teemat .
Etsi teema, jota haluat muokata, avaa toimintovalikko klikkaamalla ... -painiketta ja klikkaa sitten Muokkaa koodia .
klikkaa Sisällöt -hakemistossa valintaa theme.js
tai theme.js.liquid
.
Liitä tiedoston loppuun seuraava koodi:
document . addEventListener ( ' DOMContentLoaded ' , function () {
const productJson = document . querySelectorAll ( ' [id^=ProductJson- ' );
if ( productJson . length > 0 ) {
for ( let i = 0 ; i < productJson . length ; i ++ ) {
const current = productJson [ i ];
const sectionId = current . id . replace ( ' ProductJson- ' , '' );
const section = document . querySelector ( ' [data-section-id=" ' + sectionId + ' "] ' );
const product = JSON . parse ( current . text );
if ( product . options . length === 1 ) {
const unavailableVariants = [];
for ( let j = 0 ; j < product . variants . length ; j ++ ) {
const variant = product . variants [ j ];
if ( ! variant . available ) {
unavailableVariants . push ( variant );
}
}
if ( unavailableVariants . length > 0 ) {
const mutationCallback = function () {
const variantOptions = section . querySelectorAll ( ' .single-option-selector option ' );
if ( variantOptions . length > 0 ) {
for ( let k = 0 ; k < unavailableVariants . length ; k ++ ) {
const unavailableVariant = unavailableVariants [ k ];
for ( let l = 0 ; l < variantOptions . length ; l ++ ) {
const option = variantOptions [ l ];
if ( unavailableVariant . title === option . value ) {
option . remove ();
}
}
}
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
}
}
const observer = new MutationObserver ( mutationCallback );
const addToCartForm = document . querySelector ( ' form[action*="/cart/add"] ' );
mutationCallback ();
if ( window . MutationObserver && addToCartForm . length ) {
const config = { childList : true , subtree : true };
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
observer . observe ( addToCartForm , config );
}
}
}
}
}
});
Klikkaa Tallenna .
Loppuunmyytyjen versioiden poistaminen käytöstä
Siirry Shopify Adminissa kohtaan Verkkosivu > Teemat .
Etsi teema, jota haluat muokata, avaa toimintovalikko klikkaamalla ... -painiketta ja klikkaa sitten Muokkaa koodia .
klikkaa Sisällöt -hakemistossa valintaa theme.js
tai theme.js.liquid
.
Liitä tiedoston loppuun seuraava koodi:
document . addEventListener ( ' DOMContentLoaded ' , function () {
const productJson = document . querySelectorAll ( ' [id^=ProductJson- ' );
if ( productJson . length > 0 ) {
for ( let i = 0 ; i < productJson . length ; i ++ ) {
const current = productJson [ i ];
const sectionId = current . id . replace ( ' ProductJson- ' , '' );
const section = document . querySelector ( ' [data-section-id=" ' + sectionId + ' "] ' );
const product = JSON . parse ( current . text );
if ( product . options . length === 1 ) {
const unavailableVariants = [];
for ( let j = 0 ; j < product . variants . length ; j ++ ) {
const variant = product . variants [ j ];
if ( ! variant . available ) {
unavailableVariants . push ( variant );
}
}
if ( unavailableVariants . length > 0 ) {
const mutationCallback = function () {
const variantOptions = section . querySelectorAll ( ' .single-option-selector option ' );
if ( variantOptions . length > 0 ) {
for ( let k = 0 ; k < unavailableVariants . length ; k ++ ) {
const unavailableVariant = unavailableVariants [ k ];
for ( let l = 0 ; l < variantOptions . length ; l ++ ) {
const option = variantOptions [ l ];
if ( unavailableVariant . title === option . value ) {
option . setAttribute ( ' disabled ' , ' disabled ' );
}
}
}
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
}
}
const observer = new MutationObserver ( mutationCallback );
const addToCartForm = document . querySelector ( ' form[action*="/cart/add"] ' );
mutationCallback ();
if ( window . MutationObserver && addToCartForm . length ) {
const config = { childList : true , subtree : true };
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
observer . observe ( addToCartForm , config );
}
}
}
}
}
});
Klikkaa Tallenna .
Express
Tämän mukautuksen työvaiheet vaihtelevat sen mukaan, haluatko piilottaa loppuunmyyty-versiot kokonaan vai poistaa ne käytöstä.
Loppuunmyytyjen versioiden piilottaminen
Siirry Shopify Adminissa kohtaan Verkkosivu > Teemat .
Etsi teema, jota haluat muokata, avaa toimintovalikko klikkaamalla ... -painiketta ja klikkaa sitten Muokkaa koodia .
Valitse Ulkoasu -luettelosta theme.liquid
.
Etsi koodi </body>
. Liitä seuraava koodi sen yläpuolelle omalle rivilleen:
< script >
document . addEventListener ( ' DOMContentLoaded ' , function () {
const productJson = document . querySelectorAll ( ' [data-product-json] ' );
if ( productJson . length > 0 ) {
for ( let i = 0 ; i < productJson . length ; i ++ ) {
const current = productJson [ i ];
const section = current . closest ( ' [data-section-id] ' );
const currentJson = JSON . parse ( current . text );
if ( currentJson . options . length === 1 ) {
const unavailableVariants = [];
for ( let j = 0 ; j < currentJson . variants . length ; j ++ ) {
const variant = currentJson . variants [ j ];
if ( ! variant . available ) {
unavailableVariants . push ( variant );
}
}
if ( unavailableVariants . length > 0 ) {
const mutationCallback = function () {
const variantOptions = section . querySelectorAll ( ' .form__input--select option ' );
if ( variantOptions . length > 0 ) {
for ( let k = 0 ; k < unavailableVariants . length ; k ++ ) {
const unavailableVariant = unavailableVariants [ k ];
for ( let l = 0 ; l < variantOptions . length ; l ++ ) {
const option = variantOptions [ l ];
if ( unavailableVariant . title === option . value ) {
option . remove ();
}
}
}
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
}
}
const observer = new MutationObserver ( mutationCallback );
const addToCartForm = document . querySelector ( ' form[action*="/cart/add"] ' );
mutationCallback ();
if ( window . MutationObserver && addToCartForm . length ) {
const config = { childList : true , subtree : true };
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
observer . observe ( addToCartForm , config );
}
}
}
}
}
});
< /script>
Klikkaa Tallenna .
Loppuunmyytyjen versioiden poistaminen käytöstä
Siirry Shopify Adminissa kohtaan Verkkosivu > Teemat .
Etsi teema, jota haluat muokata, avaa toimintovalikko klikkaamalla ... -painiketta ja klikkaa sitten Muokkaa koodia .
klikkaa Sisällöt -hakemistossa valintaa theme.js
tai theme.js.liquid
.
Liitä tiedoston loppuun seuraava koodi:
< script >
document . addEventListener ( ' DOMContentLoaded ' , function () {
const productJson = document . querySelectorAll ( ' [data-product-json] ' );
if ( productJson . length > 0 ) {
for ( let i = 0 ; i < productJson . length ; i ++ ) {
const current = productJson [ i ];
const section = current . closest ( ' [data-section-id] ' );
const currentJson = JSON . parse ( current . text );
if ( currentJson . options . length === 1 ) {
const unavailableVariants = [];
for ( let j = 0 ; j < currentJson . variants . length ; j ++ ) {
const variant = currentJson . variants [ j ];
if ( ! variant . available ) {
unavailableVariants . push ( variant );
}
}
if ( unavailableVariants . length > 0 ) {
const mutationCallback = function () {
const variantOptions = section . querySelectorAll ( ' .form__input--select option ' );
if ( variantOptions . length > 0 ) {
for ( let k = 0 ; k < unavailableVariants . length ; k ++ ) {
const unavailableVariant = unavailableVariants [ k ];
for ( let l = 0 ; l < variantOptions . length ; l ++ ) {
const option = variantOptions [ l ];
if ( unavailableVariant . title === option . value ) {
option . setAttribute ( ' disabled ' , ' disabled ' );
}
}
}
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
}
}
const observer = new MutationObserver ( mutationCallback );
const addToCartForm = document . querySelector ( ' form[action*="/cart/add"] ' );
mutationCallback ();
if ( window . MutationObserver && addToCartForm . length ) {
const config = { childList : true , subtree : true };
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
observer . observe ( addToCartForm , config );
}
}
}
}
}
});
< /script>
Klikkaa Tallenna .
Minimal
Tämän mukautuksen työvaiheet vaihtelevat sen mukaan, haluatko piilottaa loppuunmyyty-versiot kokonaan vai poistaa ne käytöstä.
Loppuunmyytyjen versioiden piilottaminen
Siirry Shopify Adminissa kohtaan Verkkosivu > Teemat .
Etsi teema, jota haluat muokata, avaa toimintovalikko klikkaamalla ... -painiketta ja klikkaa sitten Muokkaa koodia .
klikkaa Sisällöt -hakemistossa valintaa theme.js
tai theme.js.liquid
.
Liitä tiedoston loppuun seuraava koodi:
document . addEventListener ( ' DOMContentLoaded ' , function () {
const productJson = document . querySelectorAll ( ' [id^=ProductJson- ' );
if ( productJson . length > 0 ) {
for ( let i = 0 ; i < productJson . length ; i ++ ) {
const current = productJson [ i ];
const sectionId = current . id . replace ( ' ProductJson- ' , '' );
const section = document . querySelector ( ' [data-section-id=" ' + sectionId + ' "] ' );
const product = JSON . parse ( current . text );
if ( product . options . length === 1 ) {
const unavailableVariants = [];
for ( let j = 0 ; j < product . variants . length ; j ++ ) {
const variant = product . variants [ j ];
if ( ! variant . available ) {
unavailableVariants . push ( variant );
}
}
if ( unavailableVariants . length > 0 ) {
const mutationCallback = function () {
const variantOptions = section . querySelectorAll ( ' .single-option-selector option ' );
if ( variantOptions . length > 0 ) {
for ( let k = 0 ; k < unavailableVariants . length ; k ++ ) {
const unavailableVariant = unavailableVariants [ k ];
for ( let l = 0 ; l < variantOptions . length ; l ++ ) {
const option = variantOptions [ l ];
if ( unavailableVariant . title === option . value ) {
option . remove ();
}
}
}
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
}
}
const observer = new MutationObserver ( mutationCallback );
const addToCartForm = document . querySelector ( ' form[action*="/cart/add"] ' );
mutationCallback ();
if ( window . MutationObserver && addToCartForm . length ) {
const config = { childList : true , subtree : true };
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
observer . observe ( addToCartForm , config );
}
}
}
}
}
});
Klikkaa Tallenna .
Loppuunmyytyjen versioiden poistaminen käytöstä
Siirry Shopify Adminissa kohtaan Verkkosivu > Teemat .
Etsi teema, jota haluat muokata, avaa toimintovalikko klikkaamalla ... -painiketta ja klikkaa sitten Muokkaa koodia .
klikkaa Sisällöt -hakemistossa valintaa theme.js
tai theme.js.liquid
.
Liitä tiedoston loppuun seuraava koodi:
document . addEventListener ( ' DOMContentLoaded ' , function () {
const productJson = document . querySelectorAll ( ' [id^=ProductJson- ' );
if ( productJson . length > 0 ) {
for ( let i = 0 ; i < productJson . length ; i ++ ) {
const current = productJson [ i ];
const sectionId = current . id . replace ( ' ProductJson- ' , '' );
const section = document . querySelector ( ' [data-section-id=" ' + sectionId + ' "] ' );
const product = JSON . parse ( current . text );
if ( product . options . length === 1 ) {
const unavailableVariants = [];
for ( let j = 0 ; j < product . variants . length ; j ++ ) {
const variant = product . variants [ j ];
if ( ! variant . available ) {
unavailableVariants . push ( variant );
}
}
if ( unavailableVariants . length > 0 ) {
const mutationCallback = function () {
const variantOptions = section . querySelectorAll ( ' .single-option-selector option ' );
if ( variantOptions . length > 0 ) {
for ( let k = 0 ; k < unavailableVariants . length ; k ++ ) {
const unavailableVariant = unavailableVariants [ k ];
for ( let l = 0 ; l < variantOptions . length ; l ++ ) {
const option = variantOptions [ l ];
if ( unavailableVariant . title === option . value ) {
option . setAttribute ( ' disabled ' , ' disabled ' );
}
}
}
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
}
}
const observer = new MutationObserver ( mutationCallback );
const addToCartForm = document . querySelector ( ' form[action*="/cart/add"] ' );
mutationCallback ();
if ( window . MutationObserver && addToCartForm . length ) {
const config = { childList : true , subtree : true };
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
observer . observe ( addToCartForm , config );
}
}
}
}
}
});
Klikkaa Tallenna .
Narrative
Tämän mukautuksen työvaiheet vaihtelevat sen mukaan, haluatko piilottaa loppuunmyyty-versiot kokonaan vai poistaa ne käytöstä.
Loppuunmyytyjen versioiden piilottaminen
Siirry Shopify Adminissa kohtaan Verkkosivu > Teemat .
Etsi teema, jota haluat muokata, avaa toimintovalikko klikkaamalla ... -painiketta ja klikkaa sitten Muokkaa koodia .
klikkaa Sisällöt -hakemistossa kohtaa custom.js
.
Liitä tiedoston loppuun seuraava koodi:
document . addEventListener ( ' DOMContentLoaded ' , function () {
const productJson = document . querySelectorAll ( ' [data-product-json] ' );
if ( productJson . length > 0 ) {
for ( let i = 0 ; i < productJson . length ; i ++ ) {
const current = productJson [ i ];
const section = current . closest ( ' [data-section-id] ' );
const product = JSON . parse ( current . text );
if ( product . options . length === 1 ) {
const unavailableVariants = [];
for ( let j = 0 ; j < product . variants . length ; j ++ ) {
const variant = product . variants [ j ];
if ( ! variant . available ) {
unavailableVariants . push ( variant );
}
}
if ( unavailableVariants . length > 0 ) {
const mutationCallback = function () {
const variantOptions = section . querySelectorAll ( ' .single-option-selector option ' );
if ( variantOptions . length > 0 ) {
for ( let k = 0 ; k < unavailableVariants . length ; k ++ ) {
const unavailableVariant = unavailableVariants [ k ];
for ( let l = 0 ; l < variantOptions . length ; l ++ ) {
const option = variantOptions [ l ];
if ( unavailableVariant . title === option . value ) {
option . remove ();
}
}
}
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
}
}
const observer = new MutationObserver ( mutationCallback );
const addToCartForm = document . querySelector ( ' form[action*="/cart/add"] ' );
mutationCallback ();
if ( window . MutationObserver && addToCartForm . length ) {
const config = { childList : true , subtree : true };
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
observer . observe ( addToCartForm , config );
}
}
}
}
}
});
Klikkaa Tallenna .
Loppuunmyytyjen versioiden poistaminen käytöstä
Siirry Shopify Adminissa kohtaan Verkkosivu > Teemat .
Etsi teema, jota haluat muokata, avaa toimintovalikko klikkaamalla ... -painiketta ja klikkaa sitten Muokkaa koodia .
klikkaa Sisällöt -hakemistossa valintaa theme.js
tai theme.js.liquid
.
Liitä tiedoston loppuun seuraava koodi:
document . addEventListener ( ' DOMContentLoaded ' , function () {
const productJson = document . querySelectorAll ( ' [data-product-json] ' );
if ( productJson . length > 0 ) {
for ( let i = 0 ; i < productJson . length ; i ++ ) {
const current = productJson [ i ];
const section = current . closest ( ' [data-section-id] ' );
const product = JSON . parse ( current . text );
if ( product . options . length === 1 ) {
const unavailableVariants = [];
for ( let j = 0 ; j < product . variants . length ; j ++ ) {
const variant = product . variants [ j ];
if ( ! variant . available ) {
unavailableVariants . push ( variant );
}
}
if ( unavailableVariants . length > 0 ) {
const mutationCallback = function () {
const variantOptions = section . querySelectorAll ( ' .single-option-selector option ' );
if ( variantOptions . length > 0 ) {
for ( let k = 0 ; k < unavailableVariants . length ; k ++ ) {
const unavailableVariant = unavailableVariants [ k ];
for ( let l = 0 ; l < variantOptions . length ; l ++ ) {
const option = variantOptions [ l ];
if ( unavailableVariant . title === option . value ) {
option . setAttribute ( ' disabled ' , ' disabled ' );
}
}
}
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
}
}
const observer = new MutationObserver ( mutationCallback );
const addToCartForm = document . querySelector ( ' form[action*="/cart/add"] ' );
mutationCallback ();
if ( window . MutationObserver && addToCartForm . length ) {
const config = { childList : true , subtree : true };
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
observer . observe ( addToCartForm , config );
}
}
}
}
}
});
Klikkaa Tallenna .
Simple
Tämän mukautuksen työvaiheet vaihtelevat sen mukaan, haluatko piilottaa loppuunmyyty-versiot kokonaan vai poistaa ne käytöstä.
Loppuunmyytyjen versioiden piilottaminen
Siirry Shopify Adminissa kohtaan Verkkosivu > Teemat .
Etsi teema, jota haluat muokata, avaa toimintovalikko klikkaamalla ... -painiketta ja klikkaa sitten Muokkaa koodia .
klikkaa Sisällöt -hakemistossa valintaa theme.js
tai theme.js.liquid
.
Liitä tiedoston loppuun seuraava koodi:
document . addEventListener ( ' DOMContentLoaded ' , function () {
const productJson = document . querySelectorAll ( ' [id^=ProductJson- ' );
if ( productJson . length > 0 ) {
for ( let i = 0 ; i < productJson . length ; i ++ ) {
const current = productJson [ i ];
const sectionId = current . id . replace ( ' ProductJson- ' , '' );
const section = document . querySelector ( ' [data-section-id=" ' + sectionId + ' "] ' );
const product = JSON . parse ( current . text );
if ( product . options . length === 1 ) {
const unavailableVariants = [];
for ( let j = 0 ; j < product . variants . length ; j ++ ) {
const variant = product . variants [ j ];
if ( ! variant . available ) {
unavailableVariants . push ( variant );
}
}
if ( unavailableVariants . length > 0 ) {
const mutationCallback = function () {
const variantOptions = section . querySelectorAll ( ' .single-option-selector option ' );
if ( variantOptions . length > 0 ) {
for ( let k = 0 ; k < unavailableVariants . length ; k ++ ) {
const unavailableVariant = unavailableVariants [ k ];
for ( let l = 0 ; l < variantOptions . length ; l ++ ) {
const option = variantOptions [ l ];
if ( unavailableVariant . title === option . value ) {
option . remove ();
}
}
}
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
}
}
const observer = new MutationObserver ( mutationCallback );
const addToCartForm = document . querySelector ( ' form[action*="/cart/add"] ' );
mutationCallback ();
if ( window . MutationObserver && addToCartForm . length ) {
const config = { childList : true , subtree : true };
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
observer . observe ( addToCartForm , config );
}
}
}
}
}
});
Klikkaa Tallenna .
Loppuunmyytyjen versioiden poistaminen käytöstä
Siirry Shopify Adminissa kohtaan Verkkosivu > Teemat .
Etsi teema, jota haluat muokata, avaa toimintovalikko klikkaamalla ... -painiketta ja klikkaa sitten Muokkaa koodia .
klikkaa Sisällöt -hakemistossa valintaa theme.js
tai theme.js.liquid
.
Liitä tiedoston loppuun seuraava koodi:
document . addEventListener ( ' DOMContentLoaded ' , function () {
const productJson = document . querySelectorAll ( ' [id^=ProductJson- ' );
if ( productJson . length > 0 ) {
for ( let i = 0 ; i < productJson . length ; i ++ ) {
const current = productJson [ i ];
const sectionId = current . id . replace ( ' ProductJson- ' , '' );
const section = document . querySelector ( ' [data-section-id=" ' + sectionId + ' "] ' );
const product = JSON . parse ( current . text );
if ( product . options . length === 1 ) {
const unavailableVariants = [];
for ( let j = 0 ; j < product . variants . length ; j ++ ) {
const variant = product . variants [ j ];
if ( ! variant . available ) {
unavailableVariants . push ( variant );
}
}
if ( unavailableVariants . length > 0 ) {
const mutationCallback = function () {
const variantOptions = section . querySelectorAll ( ' .single-option-selector option ' );
if ( variantOptions . length > 0 ) {
for ( let k = 0 ; k < unavailableVariants . length ; k ++ ) {
const unavailableVariant = unavailableVariants [ k ];
for ( let l = 0 ; l < variantOptions . length ; l ++ ) {
const option = variantOptions [ l ];
if ( unavailableVariant . title === option . value ) {
option . setAttribute ( ' disabled ' , ' disabled ' );
}
}
}
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
}
}
const observer = new MutationObserver ( mutationCallback );
const addToCartForm = document . querySelector ( ' form[action*="/cart/add"] ' );
mutationCallback ();
if ( window . MutationObserver && addToCartForm . length ) {
const config = { childList : true , subtree : true };
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
observer . observe ( addToCartForm , config );
}
}
}
}
}
});
Klikkaa Tallenna .
Supply
Tämän mukautuksen työvaiheet vaihtelevat sen mukaan, haluatko piilottaa loppuunmyyty-versiot kokonaan vai poistaa ne käytöstä.
Loppuunmyytyjen versioiden piilottaminen
Siirry Shopify Adminissa kohtaan Verkkosivu > Teemat .
Etsi teema, jota haluat muokata, avaa toimintovalikko klikkaamalla ... -painiketta ja klikkaa sitten Muokkaa koodia .
klikkaa Sisällöt -hakemistossa valintaa theme.js
tai theme.js.liquid
.
Liitä tiedoston loppuun seuraava koodi:
document . addEventListener ( ' DOMContentLoaded ' , function () {
const productJson = document . querySelectorAll ( ' [id^=ProductJson- ' );
if ( productJson . length > 0 ) {
for ( let i = 0 ; i < productJson . length ; i ++ ) {
const current = productJson [ i ];
const sectionId = current . id . replace ( ' ProductJson- ' , '' );
const section = document . querySelector ( ' [data-section-id=" ' + sectionId + ' "] ' );
const product = JSON . parse ( current . text );
if ( product . options . length === 1 ) {
const unavailableVariants = [];
for ( let j = 0 ; j < product . variants . length ; j ++ ) {
const variant = product . variants [ j ];
if ( ! variant . available ) {
unavailableVariants . push ( variant );
}
}
if ( unavailableVariants . length > 0 ) {
const mutationCallback = function () {
const variantOptions = section . querySelectorAll ( ' .single-option-selector option ' );
if ( variantOptions . length > 0 ) {
for ( let k = 0 ; k < unavailableVariants . length ; k ++ ) {
const unavailableVariant = unavailableVariants [ k ];
for ( let l = 0 ; l < variantOptions . length ; l ++ ) {
const option = variantOptions [ l ];
if ( unavailableVariant . title === option . value ) {
option . remove ();
}
}
}
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
}
}
const observer = new MutationObserver ( mutationCallback );
const addToCartForm = document . querySelector ( ' form[action*="/cart/add"] ' );
mutationCallback ();
if ( window . MutationObserver && addToCartForm . length ) {
const config = { childList : true , subtree : true };
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
observer . observe ( addToCartForm , config );
}
}
}
}
}
});
Klikkaa Tallenna .
Loppuunmyytyjen versioiden poistaminen käytöstä
Siirry Shopify Adminissa kohtaan Verkkosivu > Teemat .
Etsi teema, jota haluat muokata, avaa toimintovalikko klikkaamalla ... -painiketta ja klikkaa sitten Muokkaa koodia .
klikkaa Sisällöt -hakemistossa valintaa theme.js
tai theme.js.liquid
.
Liitä tiedoston loppuun seuraava koodi:
document . addEventListener ( ' DOMContentLoaded ' , function () {
const productJson = document . querySelectorAll ( ' [id^=ProductJson- ' );
if ( productJson . length > 0 ) {
for ( let i = 0 ; i < productJson . length ; i ++ ) {
const current = productJson [ i ];
const sectionId = current . id . replace ( ' ProductJson- ' , '' );
const section = document . querySelector ( ' [data-section-id=" ' + sectionId + ' "] ' );
const product = JSON . parse ( current . text );
if ( product . options . length === 1 ) {
const unavailableVariants = [];
for ( let j = 0 ; j < product . variants . length ; j ++ ) {
const variant = product . variants [ j ];
if ( ! variant . available ) {
unavailableVariants . push ( variant );
}
}
if ( unavailableVariants . length > 0 ) {
const mutationCallback = function () {
const variantOptions = section . querySelectorAll ( ' .single-option-selector option ' );
if ( variantOptions . length > 0 ) {
for ( let k = 0 ; k < unavailableVariants . length ; k ++ ) {
const unavailableVariant = unavailableVariants [ k ];
for ( let l = 0 ; l < variantOptions . length ; l ++ ) {
const option = variantOptions [ l ];
if ( unavailableVariant . title === option . value ) {
option . setAttribute ( ' disabled ' , ' disabled ' );
}
}
}
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
}
}
const observer = new MutationObserver ( mutationCallback );
const addToCartForm = document . querySelector ( ' form[action*="/cart/add"] ' );
mutationCallback ();
if ( window . MutationObserver && addToCartForm . length ) {
const config = { childList : true , subtree : true };
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
observer . observe ( addToCartForm , config );
}
}
}
}
}
});
Klikkaa Tallenna .
Venture
Tämän mukautuksen työvaiheet vaihtelevat sen mukaan, haluatko piilottaa loppuunmyyty-versiot kokonaan vai poistaa ne käytöstä.
Loppuunmyytyjen versioiden piilottaminen
Siirry Shopify Adminissa kohtaan Verkkosivu > Teemat .
Etsi teema, jota haluat muokata, avaa toimintovalikko klikkaamalla ... -painiketta ja klikkaa sitten Muokkaa koodia .
klikkaa Sisällöt -hakemistossa valintaa theme.js
tai theme.js.liquid
.
Liitä tiedoston loppuun seuraava koodi:
document . addEventListener ( ' DOMContentLoaded ' , function () {
const productJson = document . querySelectorAll ( ' [id^=ProductJson- ' );
if ( productJson . length > 0 ) {
for ( let i = 0 ; i < productJson . length ; i ++ ) {
const current = productJson [ i ];
const sectionId = current . id . replace ( ' ProductJson- ' , '' );
const section = document . querySelector ( ' [data-section-id=" ' + sectionId + ' "] ' );
const product = JSON . parse ( current . text );
if ( product . options . length === 1 ) {
const unavailableVariants = [];
for ( let j = 0 ; j < product . variants . length ; j ++ ) {
const variant = product . variants [ j ];
if ( ! variant . available ) {
unavailableVariants . push ( variant );
}
}
if ( unavailableVariants . length > 0 ) {
const mutationCallback = function () {
const variantOptions = section . querySelectorAll ( ' .single-option-selector option ' );
if ( variantOptions . length > 0 ) {
for ( let k = 0 ; k < unavailableVariants . length ; k ++ ) {
const unavailableVariant = unavailableVariants [ k ];
for ( let l = 0 ; l < variantOptions . length ; l ++ ) {
const option = variantOptions [ l ];
if ( unavailableVariant . title === option . value ) {
option . remove ();
}
}
}
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
}
}
const observer = new MutationObserver ( mutationCallback );
const addToCartForm = document . querySelector ( ' form[action*="/cart/add"] ' );
mutationCallback ();
if ( window . MutationObserver && addToCartForm . length ) {
const config = { childList : true , subtree : true };
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
observer . observe ( addToCartForm , config );
}
}
}
}
}
});
Klikkaa Tallenna .
Loppuunmyytyjen versioiden poistaminen käytöstä
Siirry Shopify Adminissa kohtaan Verkkosivu > Teemat .
Etsi teema, jota haluat muokata, avaa toimintovalikko klikkaamalla ... -painiketta ja klikkaa sitten Muokkaa koodia .
klikkaa Sisällöt -hakemistossa valintaa theme.js
tai theme.js.liquid
.
Liitä tiedoston loppuun seuraava koodi:
document . addEventListener ( ' DOMContentLoaded ' , function () {
const productJson = document . querySelectorAll ( ' [id^=ProductJson- ' );
if ( productJson . length > 0 ) {
for ( let i = 0 ; i < productJson . length ; i ++ ) {
const current = productJson [ i ];
const sectionId = current . id . replace ( ' ProductJson- ' , '' );
const section = document . querySelector ( ' [data-section-id=" ' + sectionId + ' "] ' );
const product = JSON . parse ( current . text );
if ( product . options . length === 1 ) {
const unavailableVariants = [];
for ( let j = 0 ; j < product . variants . length ; j ++ ) {
const variant = product . variants [ j ];
if ( ! variant . available ) {
unavailableVariants . push ( variant );
}
}
if ( unavailableVariants . length > 0 ) {
const mutationCallback = function () {
const variantOptions = section . querySelectorAll ( ' .single-option-selector option ' );
if ( variantOptions . length > 0 ) {
for ( let k = 0 ; k < unavailableVariants . length ; k ++ ) {
const unavailableVariant = unavailableVariants [ k ];
for ( let l = 0 ; l < variantOptions . length ; l ++ ) {
const option = variantOptions [ l ];
if ( unavailableVariant . title === option . value ) {
option . setAttribute ( ' disabled ' , ' disabled ' );
}
}
}
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
}
}
const observer = new MutationObserver ( mutationCallback );
const addToCartForm = document . querySelector ( ' form[action*="/cart/add"] ' );
mutationCallback ();
if ( window . MutationObserver && addToCartForm . length ) {
const config = { childList : true , subtree : true };
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
observer . observe ( addToCartForm , config );
}
}
}
}
}
});
Klikkaa Tallenna .
Osiin jakamattomien teemojen ohjeet Loppuunmyytyjen versioiden piilottaminen Jos käytät osiin jakamatonta teemaa teemaa, voit piilottaa loppuunmyydyt versiot tuotesivulta näitä ohjeita noudattamalla.
Siirry Shopify Adminissa kohtaan Verkkosivu > Teemat .
Etsi teema, jota haluat muokata, avaa toimintovalikko klikkaamalla ... -painiketta ja klikkaa sitten Muokkaa koodia .
klikkaa Koodinpätkät -hakemistossa Lisää uusi koodinpätkä .
Nimeä uusi koodinpätkäsi remove-sold-out
:
Liitä seuraava koodi uuteen koodinpätkätiedostoosi:
{% if product.options.size == 1 %}
<script>
const addToCartForm = document . querySelector ( ' form[action="/cart/add"] ' );
if ( window . MutationObserver && addToCartForm !== null ) {
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
var config = { childList : true , subtree : true };
var observer = new MutationObserver ( function () {
let variantOptions = Array . from ( document . querySelectorAll ( ' .single-option-selector option ' ));
{ % for variant in product . variants % }
{ % unless variant . available % }
variantOptions . forEach ( function ( element ) {
if ( element . value === {{ variant . title | json }}) {
element . remove ();
}
});
{ % endunless % }
{ % endfor % }
observer . disconnect ();
});
observer . observe ( addToCartForm , config );
}
</script>
{% endif %}
Klikkaa Tallenna .
Valitse Ulkoasu -luettelosta theme.liquid
.
Liitä seuraava koodi tiedoston loppuun juuri ennen </body>
-lopputunnistetta:
{% render 'remove-sold-out' %}
Klikkaa Tallenna .
Loppuunmyytyjen versioiden poistaminen käytöstä Jos käytät osiin jakamatonta teemaa teemaa, voit poistaa loppuunmyydyt versiot käytöstä näitä ohjeita noudattamalla. Versiot näkyvät edelleen tuotesivulla, mutta niitä ei voi valita.
Siirry Shopify Adminissa kohtaan Verkkosivu > Teemat .
Etsi teema, jota haluat muokata, avaa toimintovalikko klikkaamalla ... -painiketta ja klikkaa sitten Muokkaa koodia .
klikkaa Koodinpätkät -hakemistossa Lisää uusi koodinpätkä .
Nimeä uusi koodinpätkäsi disable-sold-out
:
Liitä seuraava koodi uuteen koodinpätkätiedostoosi:
{% if product.options.size == 1 %}
<script>
const addToCartForm = document . querySelector ( ' form[action="/cart/add"] ' );
if ( window . MutationObserver && addToCartForm !== null ) {
if ( typeof observer === ' object ' && typeof observer . disconnect === ' function ' ) {
observer . disconnect ();
}
var config = { childList : true , subtree : true };
var observer = new MutationObserver ( function () {
let variantOptions = Array . from ( document . querySelectorAll ( ' .single-option-selector option ' ));
{ % for variant in product . variants % }
{ % unless variant . available % }
variantOptions . forEach ( function ( element ) {
if ( element . value === {{ variant . title | json }}) {
element . setAttribute ( ' disabled ' , '' );
}
});
{ % endunless % }
{ % endfor % }
observer . disconnect ();
});
observer . observe ( addToCartForm , config );
}
</script>
{% endif %}
Klikkaa Tallenna .
Valitse Ulkoasu -luettelosta theme.liquid
.
Liitä seuraava koodi tiedoston loppuun juuri ennen </body>
-lopputunnistetta:
{% render 'disable-sold-out' %}
Klikkaa Tallenna .