/** * Creates a new, unsaved line item, but if it's a ticket line item * with a total of 0, or a subtotal of 0, returns null instead * @param EE_Line_Item $line_item * @return EE_Line_Item */ public static function non_empty_line_item(EE_Line_Item $line_item) { if ($line_item->type() === EEM_Line_Item::type_line_item && $line_item->OBJ_type() === 'Ticket' && $line_item->quantity() == 0) { return null; } $new_li_fields = $line_item->model_field_array(); //don't set the total. We'll leave that up to the code that calculates it unset($new_li_fields['LIN_ID']); unset($new_li_fields['LIN_parent']); return EE_Line_Item::new_instance($new_li_fields); }