Count Inventory Items on Invoices

Count Inventory Items on Invoices

Is there a function for me to add the inventory items in a custom field of the invoices, which only adds inventory items and not services, Example; I have an invoice with 54 items, 50 are inventory and 4 are service charges. I want a function that makes the sum in a custom field of the invoices, something similar to calculating profitability per invoice.