Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save picocodes/507f9fb13ecc1a53354b73f641069488 to your computer and use it in GitHub Desktop.
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.
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