Choose when the PDF is attached

[ad_1]

Hi @cubes91,

Although it is possible, you would need to check whether the customer has filled the company name or not. This can be done through a code snippet, like the following I just wrote for you:

/**
* PDF Invoices & Packing Slips for WooCommerce:
* Disable Invoice creation if customer doesn't provide the company name
*/
add_filter( 'wpo_wcpdf_document_is_allowed', function( $allowed, $document ) {
if ( 'invoice' === $document->type && ( $order = $document->order ) && ! $document->exists() ) {
$allowed = empty( $order->get_billing_company() ) ? false : true;
}
return $allowed;
}, 10, 2 );

If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use code snippets.

Please note that you also need to choose in which email notification you want to attach the PDF invoice (when the company name is filled). You can set this in WooCommerce > PDF Invoices > Documents > Invoice > Attach to.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer