在shopify产品页面上删除或禁用售罄的多属性步骤-ESG跨境

在shopify产品页面上删除或禁用售罄的多属性步骤

shopify新闻
shopify新闻
2022-03-28
点赞icon 0
查看icon 1066

隐藏售罄多属性


模板,不适用于“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- + 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. 点击保存

Hide sold-out variants

.

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

.

  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- + 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.



特别声明:以上文章内容仅代表作者本人观点,不代表ESG跨境电商观点或立场。如有关于作品内容、版权或其它问题请于作品发表后的30日内与ESG跨境电商联系。

搜索 放大镜
韩国平台交流群
加入
韩国平台交流群
扫码进群
欧洲多平台交流群
加入
欧洲多平台交流群
扫码进群
美国卖家交流群
加入
美国卖家交流群
扫码进群
ESG跨境专属福利分享群
加入
ESG跨境专属福利分享群
扫码进群
拉美电商交流群
加入
拉美电商交流群
扫码进群
亚马逊跨境增长交流群
加入
亚马逊跨境增长交流群
扫码进群
亚马逊跨境增长交流群
加入
亚马逊跨境增长交流群
扫码进群
拉美电商交流群
加入
拉美电商交流群
扫码进群
ESG独家招商-PHH GROUP卖家交流群
加入
ESG独家招商-PHH GROUP卖家交流群
扫码进群
《韩国平台运营干货包》
《波兰allegro知识百科》
《Darty知识百科》
《法国Fnac知识百科》
《PEAKS 出海经营方法论白皮书》
2025跨境电商营销日历
《2024年全球消费趋势白皮书——美国篇》
《2024TikTok出海达人营销白皮书》
《Coupang自注册指南》
《eMAG知识百科》
通过ESG入驻平台,您将解锁
绿色通道,更高的入驻成功率
专业1v1客户经理服务
运营实操指导
运营提效资源福利
平台官方专属优惠

立即登记,定期获得更多资讯

订阅
联系顾问

平台顾问

平台顾问 平台顾问

微信扫一扫
马上联系在线顾问

icon icon

小程序

微信小程序

ESG跨境小程序
手机入驻更便捷

icon icon

返回顶部

【免费领取】全球跨境电商运营干货 关闭
进行中
进行中
《韩国平台运营干货包》
包含四个韩国干货报告:Coupang自注册指南、GMK站内推广指南、韩国大促热销品详细预测、韩国节日营销全攻略
免费领取
进行中
进行中
TikTok运营必备干货包
包含8个TikTok最新运营指南(市场趋势、运营手册、节日攻略等),官方出品,专业全面!
免费领取
进行中
进行中
韩国电商节日营销指南
10+韩国电商重要营销节点详细解读;全年度各节日热度选品助力引爆订单增长;8大节日营销技巧轻松撬动大促流量密码。
免费领取
进行中
进行中
【平台干货】eMAG知识百科
涵盖从开店到大卖6个板块:开店、运营、广告、选品、上架、物流
免费领取
进行中
进行中
全球平台详解——全球合集
涵括全球100+个电商平台的核心信息,包括平台精炼简介、竞争优势、热销品类、入驻要求以及入驻须知等关键内容。
立即领取
进行中
进行中
韩国coupang平台自注册指南
韩国Coupang电商平台从注册准备、提交申请到完成注册,开店全流程详细指引。
免费领取
进行中
进行中
2025跨境电商营销日历
包括传统中、外重要节日及重点电商营销节点还对营销关键市场、选品辅以说明,让你的365天安排的明明白白!
免费领取
进行中
进行中
全球平台详解——欧洲篇
涵盖20+欧洲电商平台,详细解读优势、入驻条件、热销品等
立即领取
进行中
进行中
【Fnac Darty直播】夏促爆单指南
1.夏季法国本土消费趋势解析;2.促销旺季来临,选品、备货、活动等筹备指南;3.案例: 单月狂揽66万欧,中国卖家如何把握平台红利
立即报名