• Resolved sparkupart

    (@sparkupart)


    Hi, in the invoice and packing slip, the product weight shows like this 0.35000000. Is there a quick function that I can add to display it as 0.35?

    I had migrated my products from another cart and the product weight came in with the trailing zeros. It would be a lot of work to change them manually as there are more than 3000 products.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor alexmigf

    (@alexmigf)

    Hello @sparkupart

    Please add the code snippet below to your theme functions.php file:

    add_filter( 'wpo_wcpdf_order_item_data', function( $data, $order, $document_type ) {
    	if( isset( $data['weight'] ) ) {
    		$data['weight'] = number_format( $data['weight'], 2 );
    	}
    	return $data;
    }, 10, 3 );

    If you never worked with actions/filters please read this documentation page: How to use filters

    Thread Starter sparkupart

    (@sparkupart)

    Thank you so much, it worked!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Limit weight to 2 decimal places’ is closed to new replies.