• I’m trying to display decimals on the invoices but not on the rest of my site.

    How can I do that ?

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    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.
    Thread Starter db306

    (@db306)

    Hi there,

    Thanks for the reply. Your solution works perfectly, however it doesn’t seem to work on products (see screenshot)

    Invoice

    • This reply was modified 7 years, 9 months ago by db306.
    Plugin Contributor Ewout

    (@pomegranate)

    It looks to me like this is an issue with the WooCommerce calculation settings rather than with the display settings, do you see the correct product price in the order backend? (maybe share a screenshot of the order details?)

    Thread Starter db306

    (@db306)

    Hi there,

    I enter the price of the product including tax. On the backend the prices show up as rounded with no decimals. However I have a Point of Sale plugin that does display the correct price (with decimals) so I would suppose that the product on the invoice is display the rounded price with decimals.

    Plugin Contributor Ewout

    (@pomegranate)

    Hi! I don’t know where the POS plugin stores/gets its data, but if the price in the order is already rounded, there’s no way the PDF invoice plugin can undo that – it can only show decimals that are there. My guess is that the rounded prices are used during checkout and also stored that way.
    You could do a double check and install the WooCommerce Toolkit plugin (free) and then see if you see the full prices under “order items postmeta”. If you do, that does offer perspective.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Decimals on invoices only’ is closed to new replies.