Last active
February 19, 2022 08:57
-
-
Save dancameron/dafcfcdbd079c834f120 to your computer and use it in GitHub Desktop.
Adding new Line Item Types
This file contains 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 | |
/** | |
* 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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.