How to set up custom invoice numbering

From aMember Pro Documentation
Revision as of 05:38, 18 October 2012 by Caesar (talk | contribs) (Created page with "Create /amember/application/configs/site.php with this code: <source> <?php Am_Di::getInstance()->hook->add(Am_Event::INVOICE_BEFORE_INSERT, 'invoicePublicId'); function invoi...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Create /amember/application/configs/site.php with this code:


<?php 
Am_Di::getInstance()->hook->add(Am_Event::INVOICE_BEFORE_INSERT, 'invoicePublicId');
function invoicePublicId(Am_Event $event){
    $last_invoice_num = Am_Di::getInstance()->store->get('last_invoice_num');
    $invoice = $event->getInvoice();
    $invoice->public_id = date('Y_m_') . ++$last_invoice_num; //of course you can introduce your own algorithm here
    Am_Di::getInstance()->store->set('last_invoice_num', $last_invoice_num);
}