Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

woocommerce - How to display composite product weight in cart?

I am using woocommerce with composite product plugin.

I have managed to display simple product weights in the cart using the below code, but it doesn't want to display an assembled composite product.

Any help would be greatly appreciated.

add_filter( 'woocommerce_get_item_data', 
'displaying_cart_items_weight', 10, 2 );

function displaying_cart_items_weight( $item_data, $cart_item ) {
    $item_weight = $cart_item['data']->get_weight() * 
    $cart_item['quantity'];
    $item_data[] = array(
        'key'       => __('Weight', 'woocommerce'),
        'value'     => $item_weight,
        'display'   => item_weight.get_option('woocommerce_weight_unit')
    );
    return $item_data;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share

Just Browsing Browsing

[5] html - How to create even cell spacing within a

2.1m questions

2.1m answers

63 comments

56.7k users

...