Skip to content

Instantly share code, notes, and snippets.

@dancameron
Last active September 29, 2016 17:39
Show Gist options
  • Save dancameron/438f7d63f35e5c85769f2d1627a23a25 to your computer and use it in GitHub Desktop.
Save dancameron/438f7d63f35e5c85769f2d1627a23a25 to your computer and use it in GitHub Desktop.
Create Sprout Invoices
<?php
$line_items = array();
if ( !empty( $invoice_itemized_list ) ) {
foreach ( $invoice_itemized_list as $key => $item ) {
$line_items[] = array(
'rate' => ( isset( $item['price'] ) ) ? $item['price'] : '',
'qty' => ( isset( $item['quantity'] ) ) ? $item['quantity'] : '',
'desc' => ( ! isset( $item['description'] ) || ! isset( $item['name'] ) ) ? "missing name or description" : '<strong>'.$item['name'].'</strong><br/>'.$item['description'],
'type' => 'task', // task, service, product, or time
'total' => ( isset( $item['line_total_after_tax'] ) ) ? $item['line_total_after_tax'] : '',
'tax' => ( isset( $item['tax_rate'] ) ) ? $item['tax_rate'] : '',
);
}
}
$invoice->set_line_items( $line_items );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment