PPOM PRO Weight calculation
-
Here’s a tricky one for you.
I am using PPOM PRO to have an additional length input for my variable products. And it’s great!
I also use a custom snippet to calculate the weight of my items and the weight of my cart.
This weight solution no longer works properly because my new PPOM PRO ‘measure input’ field for length is not connected to the calculation.
So I need to modify my weight calculation to update the weights by multiplying the length variable from your plugin.
Can you tell me how to get find the input data from the length variable please?
Here is my current weight solution:
// Snippet 1 - Total Cart Weight // START // This snippet displays the total cart weight at the top of the basket/cart page, with a message saying "your cart weight is: __ kg" add_action('woocommerce_before_checkout_form', 'bbloomer_print_cart_weight'); add_action('woocommerce_before_cart', 'bbloomer_print_cart_weight'); function bbloomer_print_cart_weight( $posted ) { global $woocommerce; $notice = 'Your cart weight is: ' . $woocommerce->cart->cart_contents_weight . get_option('woocommerce_weight_unit'); if( is_cart() ) { wc_print_notice( $notice, 'notice' ); } else { wc_add_notice( $notice, 'notice' ); } } // END // Snippet 2 - Individual item weights // START // This snippet displays the individual weight for each item on the basket/cart page, with a message saying "Weight of item: __ kg" 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 of item', 'woocommerce'), 'value' => $item_weight, 'display' => $item_weight . ' ' . get_option('woocommerce_weight_unit') ); return $item_data; } // END- This topic was modified 7 years ago by .
- This topic was modified 7 years ago by .
- This topic was modified 7 years ago by .
The page I need help with: [log in to see the link]
The topic ‘PPOM PRO Weight calculation’ is closed to new replies.