Created
October 16, 2019 17:58
-
-
Save dancameron/e835b4ab1e5b38e2b0c4e89af3bf099c to your computer and use it in GitHub Desktop.
Set Default Line Item based on PreDefined Line Item
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 // 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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.