ÈËÉú¾ÍÊDz©¡¤(Öйú)×ðÁúAGÆì½¢Ìü

ÈËÉú¾ÍÊDz©¡¤(Öйú)×ðÁúAGÆì½¢Ìü(LianLian Global)¹ÙÍøÊ×Ò³

ÔÚshopify²úÆ·Ò³ÃæÉÑþ³Øý»ò½ûÓÃÊÛóÀµÄ¶àÊôÐÔ°ì·¨

shopifyÊÐËÁÊÐËÁÊôÐÔ
2022/03/09
×Ô½¨Õ¾

Òþ²ØÊÛóÀ¶àÊôÐÔ


±¸×¢

ÈôÊÇÄúʹÓàShopify µÄÃâ·ÑÄ£°å£¬£¬£¬£¬£¬ £¬ £¬£¬Äú¿ÉÒÔÁªÏµ Shopify Ö§³ÖÍŶӻñµÃ¹ØÓڴ˽̵̳Ä×ÊÖú ¡£ ¡£¡£¡£¡£ ¡£¡£¡£´Ë½Ì³ÌÐèÒª 15 ·ÖÖÓµÄÉè¼ÆÊ±¼ä ¡£ ¡£¡£¡£¡£ ¡£¡£¡£ÈôÒªÏàʶÏêÇ飬£¬£¬£¬£¬ £¬ £¬£¬Çë²ÎÔÄ Support for themes ¡£ ¡£¡£¡£¡£ ¡£¡£¡£

±¸×¢

´Ë×Ô½ç˵ÓÃÓÚ¸´¹Å Shopify Ä£°å£¬£¬£¬£¬£¬ £¬ £¬£¬²»ÊÊÓÃÓÚ¡°Online Store 2.0¡±Ä£°å ¡£ ¡£¡£¡£¡£ ¡£¡£¡£

  • ÕÒµ½ÄúµÄÄ£°å¼Ü¹¹°æ±¾

  • ̽Ë÷¡°Online Store 2.0¡±Ä£°å×Ô½ç˵


Äú¿ÉÒÔͨ¹ýÔÚ²úÆ·Ò³ÃæÉÑþ³Øý»ò½ûÓÃÊÛóÀµÄ¶àÊôÐÔÀ´×èÖ¹¿Í»§Ñ¡ÔñÕâЩ¶àÊôÐÔ ¡£ ¡£¡£¡£¡£ ¡£¡£¡£

±¾Ò³Ïà¹ØÖ÷Ìâ

  • ÏÞÖÆ

  • Ñ¡ÔñÄúµÄÄ£°å

ÏÞÖÆ

´ËÒ³ÃæÖиÅÊöµÄ×Ô½ç˵ÉèÖò»ÊÊÓÃÓÚÒÔÏÂÇéÐΣº

  • ÄúµÄ²úÆ·Óжà¸ö²úÆ·Ñ¡Ïî

  • ÄúʹÓàExpress Ä£°å£¬£¬£¬£¬£¬ £¬ £¬£¬²¢½«²úÆ·Ò³ÃæÉèÖÃΪÒÔµþ¼Ó·½·¨ÏÔʾ²úÆ·

·ÖÇøÄ£°åºÍδ·ÖÇøÄ£°å

±¸×¢£º±¾½Ì³ÌµÄ°ì·¨½«Æ¾Ö¤ÄúʹÓõÄÊÇ·ÖÇøÄ£°åÕÕ¾Éδ·ÖÇøÄ£°å¶øÓÐËù²î±ð ¡£ ¡£¡£¡£¡£ ¡£¡£¡£·ÖÇøÄ£°åÖ§³Öͨ¹ýÍÏ·ÅÀ´°²ÅÅÖ÷Ò³µÄ½á¹¹£¬£¬£¬£¬£¬ £¬ £¬£¬Î´·ÖÇøÄ£°åÔò²»Ö§³Ö ¡£ ¡£¡£¡£¡£ ¡£¡£¡£

ÈôÊÇÏëÏàʶÄúµÄÄ£°åÊÇ·ñÖ§³Ö·ÖÇø£¬£¬£¬£¬£¬ £¬ £¬£¬Çëתµ½Ä£°åµÄ±à¼­´úÂëÒ³Ãæ ¡£ ¡£¡£¡£¡£ ¡£¡£¡£ÈôÊÇ Sections Ä¿Â¼ÖÐÓÐÎļþ£¬£¬£¬£¬£¬ £¬ £¬£¬ÄúÔòÕýÔÚʹÓÃÒÑ·ÖÇøÄ£°å ¡£ ¡£¡£¡£¡£ ¡£¡£¡£Î´·ÖÇøÄ£°åÊÇÔÚ 2016 Äê 10 ÔÂ֮ǰÐû²¼µÄ£¬£¬£¬£¬£¬ £¬ £¬£¬²¢ÇÒ Sections Ä¿Â¼ÖÐûÓÐÎļþ ¡£ ¡£¡£¡£¡£ ¡£¡£¡£

ÈôÊÇÄúʹÓÃÒÑ·ÖÇøÄ£°å£¬£¬£¬£¬£¬ £¬ £¬£¬Çëµã»÷ Sectioned themes£¨ÒÑ·ÖÇøÄ£°å£©°´Å¥²¢Æ¾Ìý˵Ã÷¾ÙÐвÙ×÷ ¡£ ¡£¡£¡£¡£ ¡£¡£¡£ÈôÊÇÄúʹÓýϾɵÄδ·ÖÇøÄ£°å£¬£¬£¬£¬£¬ £¬ £¬£¬Çëµã»÷ Non-sectioned themes£¨Î´·ÖÇøÄ£°å£©°´Å¥²¢Æ¾Ìý˵Ã÷¾ÙÐвÙ×÷ ¡£ ¡£¡£¡£¡£ ¡£¡£¡£


  • Sectioned themes

  •  

  • Non-sectioned themes

Ñ¡ÔñÄúµÄÄ£°å

´Ë×Ô½ç˵µÄ°ì·¨ÒòÄúµÄÄ£°å¶øÒì ¡£ ¡£¡£¡£¡£ ¡£¡£¡£µã»÷Ä£°åµÄ°´Å¥£¬£¬£¬£¬£¬ £¬ £¬£¬È»ºóƾ֤ÒÔÏÂ˵Ã÷²Ù×÷£º

  • Boundless

  • Brooklyn

  • Debut

  • Express

  • Minimal

  • Narrative

  • Simple

  • Supply

  • Venture

Boundless

´Ë×Ô½ç˵ÉèÖõİ취ȡ¾öÓÚÄúÊÇÏ£ÍûÍêÈ«Òþ²ØÊÛóÀµÄ¶àÊôÐÔ£¬£¬£¬£¬£¬ £¬ £¬£¬ÕÕ¾ÉÖ»Ï뽫Æä½ûÓà ¡£ ¡£¡£¡£¡£ ¡£¡£¡£µã»÷Æ«ºÃÉèÖð´Å¥£¬£¬£¬£¬£¬ £¬ £¬£¬È»ºóƾ֤ÒÔÏÂ˵Ã÷²Ù×÷£º

  •  Disable

Òþ²ØÊÛóÀ¶àÊôÐÔ

ƾ֤ÒÔϰ취½«×Ô½ç˵ÏîÓ¦ÓÃÓÚ Boundless£º

PC£º

  1. ÔÚ Shopify ºǫ́ÖУ¬£¬£¬£¬£¬ £¬ £¬£¬×ªµ½ÔÚÏßÊÐËÁ > Ä£°å ¡£ ¡£¡£¡£¡£ ¡£¡£¡£

  2. ÕÒµ½Òª±à¼­µÄÄ£°å£¬£¬£¬£¬£¬ £¬ £¬£¬È»ºóµã»÷²Ù×÷ > ±à¼­´úÂë ¡£ ¡£¡£¡£¡£ ¡£¡£¡£

  1. ÔÚ Assets Ä¿Â¼ÖУ¬£¬£¬£¬£¬ £¬ £¬£¬µã»÷ theme.js »ò theme.js.liquid ¡£ ¡£¡£¡£¡£ ¡£¡£¡£

Æ»¹ûϵͳ£º

  1. ÔÚ Shopify Ó¦ÓÃÖУ¬£¬£¬£¬£¬ £¬ £¬£¬Çá´¥ÊÐËÁ ¡£ ¡£¡£¡£¡£ ¡£¡£¡£

  2. ÔÚÏúÊÛÇþµÀ²¿·ÖÖУ¬£¬£¬£¬£¬ £¬ £¬£¬Çá´¥ÔÚÏßÊÐËÁ ¡£ ¡£¡£¡£¡£ ¡£¡£¡£

  3. Çá´¥ Manage themes£¨ÖÎÀíÄ£°å£© ¡£ ¡£¡£¡£¡£ ¡£¡£¡£

  4. ÕÒµ½Òª±à¼­µÄÄ£°å£¬£¬£¬£¬£¬ £¬ £¬£¬È»ºóµã»÷²Ù×÷ > ±à¼­´úÂë ¡£ ¡£¡£¡£¡£ ¡£¡£¡£

  1. ÔÚ Assets Ä¿Â¼ÖУ¬£¬£¬£¬£¬ £¬ £¬£¬µã»÷ theme.js »ò theme.js.liquid ¡£ ¡£¡£¡£¡£ ¡£¡£¡£

°²×¿ÏµÍ³£º

  1. ÔÚ Shopify Ó¦ÓÃÖУ¬£¬£¬£¬£¬ £¬ £¬£¬Çá´¥ÊÐËÁ ¡£ ¡£¡£¡£¡£ ¡£¡£¡£

  2. ÔÚÏúÊÛÇþµÀ²¿·ÖÖУ¬£¬£¬£¬£¬ £¬ £¬£¬Çá´¥ÔÚÏßÊÐËÁ ¡£ ¡£¡£¡£¡£ ¡£¡£¡£

  3. Çá´¥ Manage themes£¨ÖÎÀíÄ£°å£© ¡£ ¡£¡£¡£¡£ ¡£¡£¡£

  4. ÕÒµ½Òª±à¼­µÄÄ£°å£¬£¬£¬£¬£¬ £¬ £¬£¬È»ºóµã»÷²Ù×÷ > ±à¼­´úÂë ¡£ ¡£¡£¡£¡£ ¡£¡£¡£

  1. ÔÚ Assets Ä¿Â¼ÖУ¬£¬£¬£¬£¬ £¬ £¬£¬µã»÷ theme.js »ò theme.js.liquid ¡£ ¡£¡£¡£¡£ ¡£¡£¡£

  1. ÔÚÎļþµ×²¿£¬£¬£¬£¬£¬ £¬ £¬£¬Õ³ÌùÒÔÏ´úÂ룺

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);           }         }       }     }   } });
  1. µã»÷ÉúÑÄ ¡£ ¡£¡£¡£¡£ ¡£¡£¡£

ShopifyÉÌ»§¹ÙÍøÔ­ÎÄÏêÇ飺

Hide sold-out variants

Note

If you use a free theme from Shopify, then you might be able to contact Shopify Support for help with this tutorial. It requires 15 minutes of design time. To learn more, refer to Support for themes.

Note

This customization is for vintage Shopify themes, and doesn't apply to Online Store 2.0 themes.

  • Find out your theme's architecture version

  • Explore Online Store 2.0 theme customizations

You can prevent customers from selecting sold-out variants by removing or disabling those variants on the product page.

On this page

  • Limitations

  • Select your theme

Limitations

The customizations outlined on this page do not work for the following cases:

  • Your products have more than one product option

  • You use the Express theme and have the product page set to show products in an overlay

Sectioned and non-sectioned themes

Note

The steps for this tutorial differ depending on whether you are using a sectioned or a non-sectioned theme. A sectioned theme lets you drag and drop to arrange the layout of your home page, and a non-sectioned theme doesn't.

To figure out whether your theme supports sections, go to the theme's Edit code page. If there are files in the Sections directory, you are using a sectioned theme. Non-sectioned themes were released before October 2016, and do not have files in the Sections directory.

If you are using a sectioned theme, click the Sectioned themes button and follow the instructions. If you are using an older, non-sectioned theme, click the Non-sectioned themes button and follow the instructions.


  • Sectioned themes

  • Non-sectioned themes

Select your theme

The steps for this customization vary depending on your theme. Click the button for your theme before following the instructions below:

  • Boundless

  • Brooklyn

  • Debut

  • Express

  • Minimal

  • Narrative

  • Simple

  • Supply

  • Venture

Boundless

The steps for this customization vary depending on whether you want to completely hide sold-out variants, or just disable them. Click the button for your preference before following the instructions below:

  • Hide

  • Disable

Hide sold-out variants

Follow these steps to apply the customization to Boundless:

PC£º

  1. From your Shopify admin, go to Online Store > Themes.

  2. Find the theme you want to edit, and then click Actions > Edit code.

  1. In the Assets directory, click theme.js or theme.js.liquid.

iPhone£º

  1. From the Shopify app, tap Store.

  2. In the Sales channels section, tap Online Store.

  3. Tap Manage themes.

  4. Find the theme you want to edit, and then click Actions > Edit code.

  1. In the Assets directory, click theme.js or theme.js.liquid.

Android£º

  1. From the Shopify app, tap Store.

  2. In the Sales channels section, tap Online Store.

  3. Tap Manage themes.

  4. Find the theme you want to edit, and then click Actions > Edit code.

  1. In the Assets directory, click theme.js or theme.js.liquid.

  1. At the bottom of the file, paste the following code:

    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);           }         }       }     }   } });
  2. Click Save.

ÎÄÕÂÄÚÈÝȪԴ£ºShopifyÉÌ»§¹Ù·½ÍøÕ¾


¸ü¶à
¡¾ÍøÕ¾µØÍ¼¡¿¡¾sitemap¡¿