Comments 5Rudolf started the conversationFebruary 20, 2026 at 3:03pmHi,at the moment, the custom price string is static.If you don't have a custom string, the price is taken from the default price fields.In both cases, you have to calculate the cheapest possible total price manually.Would it be possible to have the same custom price string functionality just like Bundles Products? I mean the %s variable.For me, it would be perfect if it would automatically add up just the default products. No more manual calculationWhat do you think? Thanks!Attached files: bundled products custom display price.png 1,688Dustin repliedFebruary 23, 2026 at 7:58amHi Rudolf, Please add the custom code below. (How to add custom code? ↗): add_filter( 'woocommerce_get_price_html', function ( $price, $product ) { if ( class_exists( 'WPCleverWooco' ) && $product->is_type( 'composite' ) && ( $components = $product->get_components() ) ) { if ( $product->get_pricing() === 'only' ) { return $price; } $product_id = $product->get_id(); $custom_price = stripslashes( get_post_meta( $product_id, 'wooco_custom_price', true ) ); $price = $product->get_pricing() === 'include' ? wc_get_price_to_display( $product ) : 0; foreach ( $components as $component ) { if ( ! empty( $component['default'] ) ) { // has default product if ( is_numeric( $component['default'] ) ) { // id $product_default = wc_get_product( $component['default'] ); } else { // sku $product_default = wc_get_product( wc_get_product_id_by_sku( $component['default'] ) ); } if ( ! empty( $component['price'] ) ) { // has new price $price += wc_get_price_to_display( $product_default, [ 'qty' => $component['qty'], 'price' => WPCleverWooco::get_new_price( $product_default->get_price(), $component['price'] ) ] ); } else { $price += wc_get_price_to_display( $product_default, [ 'qty' => $component['qty'] ] ); } } } if ( ! empty( $custom_price ) ) { return str_replace( '%s', wc_price( $price ), $custom_price ); } else { return wc_price( $price ); } } return $price; }, 999, 2 ); It will automatically calculate the composite price from the default component products. Alternatively, you can use "%s" in the custom price, as with Bundles.Best regards,Dustin Sign in to reply ...
Hi,
at the moment, the custom price string is static.
If you don't have a custom string, the price is taken from the default price fields.
In both cases, you have to calculate the cheapest possible total price manually.
Would it be possible to have the same custom price string functionality just like Bundles Products? I mean the %s variable.
For me, it would be perfect if it would automatically add up just the default products. No more manual calculation
What do you think? Thanks!
Attached files: bundled products custom display price.png
Hi Rudolf,
Please add the custom code below. (How to add custom code? ↗):
add_filter( 'woocommerce_get_price_html', function ( $price, $product ) { if ( class_exists( 'WPCleverWooco' ) && $product->is_type( 'composite' ) && ( $components = $product->get_components() ) ) { if ( $product->get_pricing() === 'only' ) { return $price; } $product_id = $product->get_id(); $custom_price = stripslashes( get_post_meta( $product_id, 'wooco_custom_price', true ) ); $price = $product->get_pricing() === 'include' ? wc_get_price_to_display( $product ) : 0; foreach ( $components as $component ) { if ( ! empty( $component['default'] ) ) { // has default product if ( is_numeric( $component['default'] ) ) { // id $product_default = wc_get_product( $component['default'] ); } else { // sku $product_default = wc_get_product( wc_get_product_id_by_sku( $component['default'] ) ); } if ( ! empty( $component['price'] ) ) { // has new price $price += wc_get_price_to_display( $product_default, [ 'qty' => $component['qty'], 'price' => WPCleverWooco::get_new_price( $product_default->get_price(), $component['price'] ) ] ); } else { $price += wc_get_price_to_display( $product_default, [ 'qty' => $component['qty'] ] ); } } } if ( ! empty( $custom_price ) ) { return str_replace( '%s', wc_price( $price ), $custom_price ); } else { return wc_price( $price ); } } return $price; }, 999, 2 );It will automatically calculate the composite price from the default component products. Alternatively, you can use "%s" in the custom price, as with Bundles.
Best regards,
Dustin