【问题标题】:hide product attributes if their variations are not set (WooCommerce)如果未设置其变体,则隐藏产品属性(WooCommerce)
【发布时间】:2018-04-19 11:34:42
【问题描述】:

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

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

即因为蓝色只有一种尺寸可用(其他变体未设置在变体中)。但是如果有人选择蓝色,他可以选择所有尺寸(应该只看到尺寸 M)然后获取 WooCommerce wc-no-matching-variations 信息。

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

我找到了这个,但这不起作用: Hide variations that don't match Woocommerce

【问题讨论】:

    标签: wordpress woocommerce hook-woocommerce


    【解决方案1】:

    当 WooCommerce 中有超过 30 种变体时,AJAX 将启动并阻止列表被过滤。这可以通过将其添加到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 );
    

    【讨论】:

    • 我有很多变化,所以我需要增加退货数量:return 100;
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-06-13
    • 1970-01-01
    • 2019-07-25
    • 1970-01-01
    • 1970-01-01
    • 2020-11-18
    • 2019-01-23
    相关资源
    最近更新 更多