Title: Skip Invoice creation
Last modified: July 16, 2022

---

# Skip Invoice creation

 *  Resolved [jpelayo](https://wordpress.org/support/users/jpelayo/)
 * (@jpelayo)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/skip-invoice-creation/)
 * Hi,
 * Please, is it possible to skip invoice creation/association to an order based
   on the payment method (CoD for instance) ?
 * This might be a possible implementation in the functions.php, but a hook would
   need to be available – and maybe it is – :
 *     ```
       // exclude certain payment methods from automatic pdf creation
       add_filter( 'wpo_wcpdf_custom_attachment_condition', 'wpo_wcpdf_exclude_payment_method', 100, 4 );
       function wpo_wcpdf_exclude_payment_method ( $condition, $order, $status, $document ) {
       	$excluded_methods = array( 'cod', 'bacs' );
       	$payment_method = get_post_meta( $order->id, '_payment_method', true );
       	if ( $document == 'invoice' && in_array( $payment_method, $excluded_methods ) ) {
       		return false;
       	} else {
       		return $condition;
       	}
       }
       ```
   
 * For now I will try a modified version of invoice.php at line 437 :
 *     ```
       $payment_method=$order->get_payment_method();
       $excluded_methods = array( 'cod', 'bacs' );
       $free_order_enable = Wf_Woocommerce_Packing_List::get_option('wf_woocommerce_invoice_free_orders',$this->module_id);
       $invoice_creation = 1;
       if(($free_order_enable == "No")|| in_array( $payment_method, $excluded_methods )){
         if(\intval($order->get_total()) === 0){
           $invoice_creation = 0;
         }
       }
       ```
   
 * Thank you.
    -  This topic was modified 3 years, 10 months ago by [jpelayo](https://wordpress.org/support/users/jpelayo/).
    -  This topic was modified 3 years, 10 months ago by [jpelayo](https://wordpress.org/support/users/jpelayo/).
      Reason: added php code
    -  This topic was modified 3 years, 10 months ago by [jpelayo](https://wordpress.org/support/users/jpelayo/).

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

 *  Thread Starter [jpelayo](https://wordpress.org/support/users/jpelayo/)
 * (@jpelayo)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/skip-invoice-creation/#post-15830699)
 * Code corrected, better at line 407 and 441 :
 * ‘
    $payment_method=$order->get_payment_method(); $excluded_methods = array( ‘
   cod’, ‘bacs’ ); if(in_array( $payment_method, $excluded_methods )){ $invoice_creation
   = 0; } ‘
 * But, anyway,… it does not work.
    -  This reply was modified 3 years, 10 months ago by [jpelayo](https://wordpress.org/support/users/jpelayo/).
    -  This reply was modified 3 years, 10 months ago by [jpelayo](https://wordpress.org/support/users/jpelayo/).
 *  Thread Starter [jpelayo](https://wordpress.org/support/users/jpelayo/)
 * (@jpelayo)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/skip-invoice-creation/#post-15830982)
 * This was needed for it to work:
 *     ```
       echo self::generate_invoice_number($order,false);
       ```
   
 * instead of
 *     ```
       echo self::generate_invoice_number($order,$force_generate);
       ```
   
 * in the function
 *     ```
       public function add_invoice_column_value($column)
       ```
   
 * of invoice.php
 *  Plugin Author [WebToffee](https://wordpress.org/support/users/webtoffee/)
 * (@webtoffee)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/skip-invoice-creation/#post-15845609)
 * Hi [@jpelayo](https://wordpress.org/support/users/jpelayo/),
 * Greetings from WebToffee!
 * We understand your requirement. However, our plugin currently doesn’t offer any
   options/hooks to skip the invoice creation based on the payment method. Thanks
   for understanding.

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

The topic ‘Skip Invoice creation’ is closed to new replies.

 * ![](https://ps.w.org/print-invoices-packing-slip-labels-for-woocommerce/assets/
   icon-256x256.gif?rev=3123111)
 * [WebToffee WooCommerce PDF Invoices, Packing Slips, Delivery Notes & Shipping Labels](https://wordpress.org/plugins/print-invoices-packing-slip-labels-for-woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/print-invoices-packing-slip-labels-for-woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/print-invoices-packing-slip-labels-for-woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/print-invoices-packing-slip-labels-for-woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/print-invoices-packing-slip-labels-for-woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/print-invoices-packing-slip-labels-for-woocommerce/reviews/)

## Tags

 * [exclude](https://wordpress.org/support/topic-tag/exclude/)
 * [functions](https://wordpress.org/support/topic-tag/functions/)
 * [hook](https://wordpress.org/support/topic-tag/hook/)
 * [prevent](https://wordpress.org/support/topic-tag/prevent/)

 * 3 replies
 * 2 participants
 * Last reply from: [WebToffee](https://wordpress.org/support/users/webtoffee/)
 * Last activity: [3 years, 9 months ago](https://wordpress.org/support/topic/skip-invoice-creation/#post-15845609)
 * Status: resolved