Hi! You can do this by applying the following filter:
// add the filter only when creating a pdf
add_action( 'wpo_wcpdf_before_pdf', 'wpo_wcpdf_set_decimals' );
function wpo_wcpdf_set_decimals ( $template_type ) {
add_filter( 'wc_price_args', 'wpo_wcpdf_decimals_filter' );
}
function wpo_wcpdf_decimals_filter( $args ) {
$args['decimals'] = 2;
return $args;
}
// clean up after ourselves
add_action( 'wpo_wcpdf_after_pdf', 'wpo_wcpdf_unset_decimals' );
function wpo_wcpdf_unset_decimals ( $template_type ) {
remove_filter( 'wc_price_args', 'wpo_wcpdf_decimals_filter' );
}
Read this if you haven’t worked with filters before: How to use filters
Hope that helps!
Ewout
-
This reply was modified 7 years, 10 months ago by Ewout.