Skip to content

Instantly share code, notes, and snippets.

@dancameron
Created October 16, 2019 17:58
Show Gist options
  • Save dancameron/e835b4ab1e5b38e2b0c4e89af3bf099c to your computer and use it in GitHub Desktop.
Save dancameron/e835b4ab1e5b38e2b0c4e89af3bf099c to your computer and use it in GitHub Desktop.
Set Default Line Item based on PreDefined Line Item
<?php // don't add this line since it's already in your functions.php file
function si_lineitem_default_on_pdli( $columns = array(), $type ) {
if ( '' != $type || 'default' != $type ) {
return $columns;
}
$columns['desc']['value'] = $item->get_content();
$columns['rate']['value'] = $item->get_default_rate();
$columns['qty']['value'] = $item->get_default_qty();
$columns['tax']['value'] = $item->get_default_percentage();
$columns['sku']['value'] = $item->get_default_sku();
return $columns;
}
add_filter( 'si_line_item_columns', 'si_lineitem_default_on_pdli', 10, 2 );
@dancameron
Copy link
Author

This snippet is a customization for Sprout Invoices. A customizable solution that provides a way for you to get paid via your WordPress site. For more information please don't hesitate to reach out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment