我想从购物车页面中删除特定类别的“数量”标题

时间:2019-07-16 17:40:26

标签: woocommerce cart

这是到目前为止的代码

add_filter( 'woocommerce_quantity_input_args', 'hide_quantity_input_field', 20, 2 );

function hide_quantity_input_field( $args, $product ) {
    // Here set your product categories in the array (can be either an ID, a slug, a name or an array)
    $categories = array('3-months-sub','shoes');

    // Handling product variation
    $the_id = $product->is_type('variation') ? $product->get_parent_id() : $product->get_id();

    // Only on cart page for a specific product category
    if( is_cart() && has_term( $categories, 'product_cat', $the_id ) ) {
        $input_value = $args['input_value'];
        $args['min_value'] = $args['max_value'] = $input_value;
    }

    return $args;
}

0 个答案:

没有答案