Created
June 15, 2017 17:51
-
-
Save dancameron/2152f456f6375c2badd602494331eb78 to your computer and use it in GitHub Desktop.
Automatically Send Invoice After Set to Pending
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // don't include this in your functions.php, since the start of the file should already have it | |
function maybe_send_invoice_notification( SI_Invoice $invoice, $status = '' ) { | |
if ( SI_Invoice::STATUS_PENDING === $status ) { | |
$client = $invoice->get_client(); | |
if ( ! is_a( $client, 'SI_Client' ) ) { | |
return; | |
} | |
$recipients = $client->get_associated_users(); | |
if ( empty( $recipients ) ) { | |
return; | |
} | |
do_action( 'send_invoice', $invoice, $recipients ); | |
} | |
} | |
add_action( 'si_invoice_status_updated', 'maybe_send_invoice_notification', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment