Skip to content

Instantly share code, notes, and snippets.

@dancameron
Created January 9, 2020 16:17
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/7796e79b779d63bac1dae12930be4d91 to your computer and use it in GitHub Desktop.
Save dancameron/7796e79b779d63bac1dae12930be4d91 to your computer and use it in GitHub Desktop.
<?php // don't include this line in your functions.php, since it already starts with it.
function fee_line_item_types( $types = array() ) {
$types = array(
'task' => __( 'Task', 'sprout-invoices' ),
'service' => __( 'Service', 'sprout-invoices' ),
'product' => __( 'Product', 'sprout-invoices' ),
'fee' => __( 'Fees', 'sprout-invoices' ),
);
return $types;
}
add_filter( 'si_line_item_types', 'fee_line_item_types' );
function fee_type_options( $columns = array(), $type = 'fee' ) {
if ( 'fee' === $type ) {
$columns = array(
'_id' => array(
'type' => 'hidden',
'value' => mt_rand(),
'weight' => 0,
),
'desc' => array(
'label' => __( 'Fees', 'sprout-invoices' ),
'type' => 'textarea',
'calc' => false,
'hide_if_parent' => false,
'weight' => 1,
),
'sku' => array(
'type' => 'hidden',
'placeholder' => '',
'calc' => false,
'numeric' => false,
'weight' => 3,
),
'rate' => array(
'label' => __( 'Amount', 'sprout-invoices' ),
'type' => 'small-input',
'calc' => false,
'hide_if_parent' => true,
'weight' => 5,
),
'qty' => array(
'type' => 'hidden',
'placeholder' => 1,
'calc' => true,
'hide_if_parent' => true,
'weight' => 10,
),
'tax' => array(
'label' => sprintf( '&#37; <span class="helptip" title="%s"></span>', __( 'A percentage adjustment per line item, i.e. tax or discount', 'sprout-invoices' ) ),
'type' => 'hidden',
'calc' => false,
'hide_if_parent' => true,
'weight' => 15,
),
'total' => array(
'label' => __( 'Total', 'sprout-invoices' ),
'type' => 'total',
'placeholder' => sa_get_formatted_money( 0 ),
'calc' => true,
'hide_if_parent' => false,
'weight' => 50,
),
);
}
return $columns;
}
add_filter( 'si_line_item_columns', 'fee_type_options', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment