Created
March 6, 2020 00:58
-
-
Save ronalfy/1589d0fa68f9a7802679f516ffa00c15 to your computer and use it in GitHub Desktop.
Paid Memberships Pro Invoice Code
This file contains hidden or 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
<?php | |
function pmpro_invoice_code_helfer( $code ) { | |
$invoice_code = get_option( 'pmpro_helfer_invoice_code', array() ); | |
if ( empty( $invoice_code ) ) { | |
$invoice_code = array( | |
'prefix' => 'IAW', | |
'increment' => 1, | |
); | |
update_option( 'pmpro_helfer_invoice_code', $invoice_code ); | |
} | |
$increment = absint( $invoice_code['increment'] ); | |
$increment++; | |
$invoice_code['increment'] = $increment; | |
update_option( 'pmpro_helfer_invoice_code', $invoice_code ); | |
return $invoice_code['prefix'] . zeroise( $invoice_code['increment'], 10 ); | |
} | |
add_filter( 'pmpro_random_code', 'pmpro_invoice_code_helfer' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment