Skip to content

Instantly share code, notes, and snippets.

@dancameron
Last active February 19, 2022 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dancameron/dafcfcdbd079c834f120 to your computer and use it in GitHub Desktop.
Save dancameron/dafcfcdbd079c834f120 to your computer and use it in GitHub Desktop.
Adding new Line Item Types
<?php // don't add this line since it's already in your functions.php file
/**
* Changing the line item labels/names and adding a new line item type.
*
*/
function add_new_line_item_types( $types = array() ) {
$array_of_new_types = array(
'tasks' => __( 'Labour' ), // change label for tasks
'product' => __( 'Equipment' ), // change labal for product
'expenses' => __( 'Expenses' ), // add new type
);
$types = array_merge( $types, $array_of_new_types );
return $types;
}
add_filter( 'si_line_item_types', 'add_new_line_item_types' );
/**
* Example of changing the line item type options.
*
*/
function modify_type_options( $columns = array(), $type = 'expenses' ) {
if ( 'expenses' === $type ) {
// modify the columns array for the expenses type
}
return $columns;
}
add_filter( 'si_line_item_columns', 'modify_type_options', 10, 2 );
@prashtrade
Copy link

I used this code using code snippet, it added the extra line items like Expenses, Equipment, Labour are being shown only in the dropdown list but when I select these new line items to add, only default line items are getting added i.e. Tasks and Services. Newly added line items are not getting added.

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