• Resolved Mementox

    (@mementox)


    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 to see the link]

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

    (@kluver)

    Hi @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

    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

    Thread Starter Mementox

    (@mementox)

    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.