Skip to content

Instantly share code, notes, and snippets.

@dancameron
Last active August 15, 2016 22:41
Show Gist options
  • Save dancameron/346415eba8eb33acb65a to your computer and use it in GitHub Desktop.
Save dancameron/346415eba8eb33acb65a to your computer and use it in GitHub Desktop.
Automatically Send Invoice after it's Auto Generated
<?php
function auto_send_invoice_after_creation( $old_invoice_id, $new_invoice_id ) {
$invoice = SI_Invoice::get_instance( $new_invoice_id );
$client = $invoice->get_client();
$client_users = $client->get_associated_users();
if ( !empty( $client_users ) ) {
do_action( 'send_invoice', $invoice, $client_users );
}
}
add_action( 'si_recurring_invoice_created', 'auto_send_invoice_after_creation', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment