Skip to content

Instantly share code, notes, and snippets.

@dancameron
Created October 17, 2019 15:29
Show Gist options
  • Save dancameron/f21246f901203e9bcfcd3c03e7a2ada1 to your computer and use it in GitHub Desktop.
Save dancameron/f21246f901203e9bcfcd3c03e7a2ada1 to your computer and use it in GitHub Desktop.
Default Line Items
<?php // don't include this line in your functions.php, since it already starts with it.
function set_line_item_defaults( $columns = array(), $type ) {
if ( 'service' !== $type ) {
return $columns;
}
$columns['desc']['value'] = 'This is the default text';
$columns['rate']['value'] = 125;
$columns['tax']['value'] = 0;
$columns['total']['value'] = 125;
return $columns;
}
add_filter( 'si_line_item_columns', 'set_line_item_defaults', 10, 2 );
function _set_default_line_item_type( $old_default ) {
return 'service';
}
add_filter( 'si_get_default_line_item_type', '_set_default_line_item_type' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment