Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Elana Davis

    (@elanasparkle)

    Hello @aggk,

    ?Thank you for reaching out to support! You can do it a few different ways but the easiest way would be to add the action of sa_new_invoice after your invoice is created. You would want to make sure you set the status to pending beforehand. I do that with SI_Invoice STATUS_PENDING like in the below Gist. Also, below is the full function to send a notification on invoice creation.

    https://gist.github.com/elanasparkle/104bec2ae0b6f93e47200b219e2a7d55

    function send_invoice_on_creation( SI_Invoice $invoice ) {
    	$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( 'sa_new_invoice',  'send_invoice_on_creation' );

    Let me know if that works for you or if you need anything further.

    Thanks
    Elana D.

    Plugin Contributor Elana Davis

    (@elanasparkle)

    Hello @aggk,

    I haven’t heard from you and per our support policies, I’m going to mark this as resolved. Don’t hesitate to reach out if you are still having any issues or need anything further.

    Thanks
    Elana D.

    Is this snippet required for the paid/Freelancer version or is the invoice emailed automatically on creation? With both manually and recurring?

    Plugin Contributor Elana Davis

    (@elanasparkle)

    Hello @ski_k2,

    For the recurring invoices the notification will go out automatically, along with the invoices scheduled for future dates. If you are manually creating an invoice for today you would need to send the notification in the notification section of the edit invoice screen. However, this hook will remove that manual process for newly created invoices and always send the notification on manual invoices that are not scheduled for the future.

    Thanks
    Elana D.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Notifications programmatically?’ is closed to new replies.