To get compatibility with "WooCommerce Chained Products" plugin use the below code snippet.
https://woocommerce.com/ products/chained-products/
add_filter('thwepo_product_price', 'thwepo45r_product_price', 3, 99); function thwepo45r_product_price($price, $product, $is_default){ $product_id = $product->get_id(); global $wc_chained_products; $prices = array(); $prices[$product_id] = $product->get_price(); $chained_items = $wc_chained_products->get_all_chained_product_details($product_id); if ( ! empty( $chained_items ) ) { foreach ( $chained_items as $chained_item_id => $chained_item_data ) { $chained_product = wc_get_product( $chained_item_id ); $priced_individually = ( ! empty( $chained_item_data['priced_individually'] ) ) ? $chained_item_data['priced_individually'] : 'no'; if ( $chained_product instanceof WC_Product && 'yes' === $priced_individually ) { $chained_product_price = $chained_product->get_price(); if ( ! empty( $chained_product_price ) ) { $prices[$chained_item_id] = $chained_product_price * $chained_item_data['unit']; } $override_price = true; } } } if(!empty($prices)){ $price = array_sum( $prices ); } return $price; } add_filter('thwepo_skip_extra_options_for_cart_item', 'thwepo36t_skip_extra_options', 4, 99); function thwepo36t_skip_extra_options($skip, $cart_item_data, $product_id, $variation_id){ $skip = (isset($cart_item_data['chained_item_of'])) ? true : false; return $skip; }
Comments
0 comments
Please sign in to leave a comment.