How to Enable Automatic Invoices for Bank Transfers?

The following PHP snippet can be used to enable automatic invoices for Bank Transfer. 

This snippet will first create a recurring item and then add it to an invoice. It will then generate invoices based on the schedule defined for the recurring items.
We recommend using the Code Snippets plugin for adding PHP snippets to your site. 
<?php
// Let bank transfer show up for recurring items.
function getpaid_automatic_invoices_force_enable_gateways( $gateways ) {
    if ( wpinv_is_gateway_active( 'bank_transfer' ) ) {
        $gateways[] = 'bank_transfer';
}
    return array_unique( $gateways );
}

add_filter( 'getpaid_submission_gateways', 'getpaid_automatic_invoices_force_enable_gateways', 1 );
add_filter( 'getpaid_bank_transfer_supports_subscription', '__return_true' );

/**
 * Renew invoice.
 *
 * @param WPInv_Subscription $subscription
 */

function getpaid_automatic_invoices_maybe_renew_invoice( $subscription ) {
    if ( $subscription->get_gateway() !== 'bank_transfer' ) {
        $subscription->create_payment();
    }
}

add_action( 'getpaid_should_renew_subscription', 'getpaid_automatic_invoices_maybe_renew_invoice' );

Still need help? Contact Us Contact Us