Title: Avoid create pdf based on a custom field
Last modified: June 28, 2019

---

# Avoid create pdf based on a custom field

 *  Resolved [Mementox](https://wordpress.org/support/users/mementox/)
 * (@mementox)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/avoid-create-pdf-based-on-a-custom-field/)
 * Hi!
    On checkout page we have a custom field that to choose if the buyer wants
   invoice or not. If the buyer doesn’t want invoice, we don’t want to generate 
   invoice for this order.
 * Is it possible to do this wiht filter or something like this?
 * Regards!
    Thanks!
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Favoid-create-pdf-based-on-a-custom-field%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Contributor [kluver](https://wordpress.org/support/users/kluver/)
 * (@kluver)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/avoid-create-pdf-based-on-a-custom-field/#post-11682667)
 * Hi [@mementox](https://wordpress.org/support/users/mementox/),
 * That is certainly possible. You will need a small code snippet:
 *     ```
       add_filter( 'wpo_wcpdf_custom_attachment_condition', 'wpo_wcpdf_check_for_checkout_invoice_option', 100, 4 );
       function wpo_wcpdf_check_for_checkout_invoice_option( $condition, $order, $status, $document ) {
       	if ($document == 'invoice' && $order->get_meta('your_meta_key_here') == 'your meta value here' ) {
       		return false;
       	} else {
       		return $condition;
       	}
       }
       ```
   
 * You will have to replace `your_meta_key_here` and `'your meta value here'` with
   the meta key of your custom checkout field and the value that is saved when the
   user does not want an invoice. If you are having trouble finding the meta key
   and its value you can read the following guide: [Finding WooCommerce custom fields](https://docs.wpovernight.com/general/finding-woocommerce-custom-fields/)
 * This code snippet should be placed in the functions.php of your child theme. 
   IF you haven’t worked with code snippets or functions.php before please read 
   this: [How to use filters](https://docs.wpovernight.com/general/how-to-use-filters/)
 *  Thread Starter [Mementox](https://wordpress.org/support/users/mementox/)
 * (@mementox)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/avoid-create-pdf-based-on-a-custom-field/#post-11687623)
 * Yes, it works perfectly!
 * Thank you so much!!
    Regards!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Avoid create pdf based on a custom field’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce-pdf-invoices-packing-slips/assets/icon-256x256.
   png?rev=2189942)
 * [PDF Invoices & Packing Slips for WooCommerce](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/reviews/)

## Tags

 * [generate](https://wordpress.org/support/topic-tag/generate/)
 * [pdf](https://wordpress.org/support/topic-tag/pdf/)

 * 2 replies
 * 2 participants
 * Last reply from: [Mementox](https://wordpress.org/support/users/mementox/)
 * Last activity: [6 years, 10 months ago](https://wordpress.org/support/topic/avoid-create-pdf-based-on-a-custom-field/#post-11687623)
 * Status: resolved