Created
January 28, 2021 07:01
-
-
Save picocodes/507f9fb13ecc1a53354b73f641069488 to your computer and use it in GitHub Desktop.
This code automatically creates an invoice at the start of the month and notifies the customer.
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( 'getpaid_daily_maintenance', 'getpaid_generate_invoice_monthly_1611816820' ); | |
function getpaid_generate_invoice_monthly_1611816820() { | |
// Check if this is the first day of month. | |
if ( date( 'j' ) === '1' ) { | |
$invoice = new WPInv_Invoice(); | |
$invoice->set_user_id( $user_id ); // Replace user id with the user id. | |
$invoice->add_item( $item_id ); // Replace item id with the item id. | |
$invoice->set_due_date( strtotime( '+5 days', current_time( 'timestamp' ) ) ); // Set the due date five days from now. | |
$invoice->save(); // Save the invoice and send a notification to the customer. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment