如果未设置其变体,则隐藏产品属性(WooCommerce) [英] hide product attributes if their variations are not set (WooCommerce)

查看:50
本文介绍了如果未设置其变体,则隐藏产品属性(WooCommerce)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果未设置商品属性,如何隐藏其属性.示例:我有3种不同的颜色和3种不同的尺寸.但并非每种颜色都存在每种颜色:

How to hide product attributes if their variations are not set. Example: I have 3 different colors and 3 different sizes. But not for every color every size exists:

  • 蓝色>>> M
  • 黄色>>> M,L,XL
  • 绿色>>> M,L,XL

即对于蓝色,只有一种尺寸可用(其他变化不设置变化).但是,如果有人选择蓝色,他可以选择所有尺寸(只能看到M号),然后获取WooCommerce wc-no-matching-variations信息.

I.e. for blue is only one size available (other variations arent set in variations). But if someone chooses blue, he can choose all sizes (should only see size M) and then get the WooCommerce wc-no-matching-variations info .

如果选择了蓝色,如何隐藏其他尺寸选项?

How to hide the other size-options if blue is selected?

我发现了这个,但这不起作用:隐藏与Woocommerce不匹配的变体

I found this, but this isnt working: Hide variations that don't match Woocommerce

推荐答案

当WooCommerce的版本超过30种时,AJAX将加入并阻止列表被过滤.可以通过将其添加到functions.php

When there are more than 30 variations in WooCommerce, AJAX will kick in and prevent the list from being filtered . This can be modified by adding this into functions.php

function custom_wc_ajax_variation_threshold( $qty, $product ) {
    return 10;
}

add_filter( 'woocommerce_ajax_variation_threshold', 'custom_wc_ajax_variation_threshold', 10, 2 );

这篇关于如果未设置其变体,则隐藏产品属性(WooCommerce)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆