By default, WooCommerce Product Add Ons Ultimate displays a set of subtotals showing the user how the total product price is arrived at.
However, if you prefer, you can either hide these subtotals altogether or just display the total cost of the product including the value of Product Add Ons fields.
To do this:
- From the front end, go to Customizer > WooCommerce > WooCommerce Product Add Ons Ultimate
- From the back end, go to WooCommerce > Settings > WooCommerce Product Add Ons Ultimate
From ‘Display totals fields’, choose whether to show or hide the subtotal breakdown, or just display the total price.
If you choose ‘Totals only’ and you want to add some text before the total, use this snippet:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function prefix_pewc_total_only_text( $label, $post_id ) { | |
return __( 'Total: ' ); | |
} | |
add_filter( 'pewc_total_only_text', 'prefix_pewc_total_only_text', 10, 2 ); |
You can also add a snippet that will let you show / hide the totals fields depending on the product:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function demo_pewc_product_show_totals( $show_totals, $post_id ) { | |
// Show the Totals fields for product IDs in the array | |
$totals = array( 64, 66, 454 ); | |
if( in_array( $post_id, $totals ) ) { | |
$show_totals = 'total'; | |
} | |
// Hide the Totals fields for product IDs in this array | |
if( in_array( $post_id, array( 969, 1111 ) ) ) { | |
$show_totals = 'hide'; | |
} | |
return $show_totals; | |
} | |
add_filter( 'pewc_product_show_totals', 'demo_pewc_product_show_totals', 10, 2 ); |
This is how to add a snippet.