Last active
June 22, 2020 20:37
-
-
Save grantalltodavid/ef2ecef341e8caff8de6adba1012547d to your computer and use it in GitHub Desktop.
Sliced Invoices: automatically send quote to client upon invoice creation
This file contains 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
add_action( 'new_to_publish', 'sliced_auto_send_quote', 10, 1 ); | |
add_action( 'draft_to_publish', 'sliced_auto_send_quote', 10, 1 ); | |
add_action( 'pending_to_publish', 'sliced_auto_send_quote', 10, 1 ); | |
add_action( 'sliced_auto_send_quote_deferred', 'sliced_auto_send_quote_deferred_function', 10, 1 ); | |
function sliced_auto_send_quote( $post ) { | |
if ( $post->post_type === 'sliced_quote' ) { | |
// run in background | |
wp_schedule_single_event( time(), 'sliced_auto_send_quote_deferred', array( $post ) ); | |
} | |
} | |
function sliced_auto_send_quote_deferred_function( $post ) { | |
if ( $post->post_type === 'sliced_quote' ) { | |
$sliced_notifications = Sliced_Notifications::get_instance(); | |
$sliced_notifications->send_the_quote( $post->ID ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment