@alexmigf thank you for your help. I have modified the snippet you create because actually we need to exclude only one product. The new snippet will compare the product ID and unset it from the invoice:
add_filter( 'wpo_wcpdf_order_items_data', function( $items, $order, $document_type ) {
$product_to_exclude = 10324;
if( ! empty( $items ) && ! empty( $order ) ) {
foreach( $items as $item_id => $item ) {
$product_id = $item['variation_id'] != 0 ? $item['variation_id'] : $item['product_id'];
if( $product_id == $product_to_exclude ) {
unset( $items[$item_id] );
}
}
}
return $items;
}, 10, 3 );
The problem is that when generating the invoice the subtotal and total are still calculating the value of the product. In this case we have made a test using the product to exclude (was 50€). So the invoice generated is empty of items but the calculation is still happening.
We need this type of functionality because we are selling Gift Cards, and we don’t need them to be invoiced. We want to exclude this product from invoices.
Please see: invoice screenshot
-
This reply was modified 3 years, 8 months ago by Daniel P..