function commerce_billy_apply_invoice_nr_pattern in Commerce Billy 7
Helper function that applies the invoice number pattern by replacing tokens and the {id} placeholder.
3 calls to commerce_billy_apply_invoice_nr_pattern()
- commerce_billy_invoice_nr_infinite in ./
commerce_billy.module - Generated infinite invoice number.
- commerce_billy_invoice_nr_monthly in ./
commerce_billy.module - Generated monthly invoice number.
- commerce_billy_invoice_nr_yearly in ./
commerce_billy.module - Generated yearly invoice number.
File
- ./
commerce_billy.module, line 174 - Commerce Billy module.
Code
function commerce_billy_apply_invoice_nr_pattern($nr_array) {
$pattern = variable_get('commerce_billy_invoice_nr_pattern', '[date:custom:Y]-{id}');
$invoice_id = str_pad($nr_array['id'], variable_get('commerce_billy_invoice_nr_padding', 0), '0', STR_PAD_LEFT);
$new_nr = str_replace('{id}', $invoice_id, $pattern);
$new_nr = token_replace($new_nr, array(), array(
'clear' => TRUE,
));
return $new_nr;
}