Skip to content

Instantly share code, notes, and snippets.

@justinstern
Created June 10, 2014 04:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinstern/af2413a2a648d7fc2a1b to your computer and use it in GitHub Desktop.
Save justinstern/af2413a2a648d7fc2a1b to your computer and use it in GitHub Desktop.
Snippet to automatically assign a invoice number to an order when payment is successfully completed http://www.woothemes.com/products/print-invoices-packing-lists/
<?php
// Add the following to the bottom of your theme's functions.php
add_action( 'woocommerce_payment_complete', 'set_pip_invoice_number' );
function set_pip_invoice_number( $order_id ) {
$order = new WC_Order( $order_id );
if ( in_array( $order->status, array( 'processing', 'completed' ) ) && function_exists( 'woocommerce_pip_invoice_number' ) ) {
woocommerce_pip_invoice_number( $order_id );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment