Custom Product Costs For WooCommerce
What Does This Feature Do?
This feature allows you to assign custom product costs to each product in WooCommerce in addition to the Product Cost Of Goods.
Example usage is if you want to track your packing fees or packaging costs seperately to the product cost of goods.
These additional costs are used in your total profit calculations as part of Alpha Insights and displayed for each order as well as in our reporting dashboards.
How Does This Feature Work?
You can set up as many custom product costs as you’d like from Alpha Insights > General settings.
Each custom cost has two main calculation settings.
% Of Sell Price: This is calculated as a percentage of the sell price of the product at the time.
Static Fee: This is a static value that will be assigned for each unit sold.
Both of these values are combined to give a default cost price for this custom product cost.
The values you enter are per unit sold.
Once you have saved these settings, this custom cost field will appear in:
- The product edit page, where you can set product specific values (if not set, they will default to the values assigned in general settings).
- On the order edit page for each line item where you can override the value for that specific order. These values are also combined into a “Total Custom Product Cost” input in the cost overrides section of the order edit page by Alpha Insights. If you input a value here it will override all calculations.
Setting Up Your Custom Product Costs
1. Setup Default Product Costs – Alpha Insights > General Settings
To create a new custom product cost enter a name for the cost, the percent of the sell price & a static fee.
You can set percent of sell price and/or static fee to 0 if you’d like to only assign these costs manually for each order from the order edit page.
The Percent Of Sell Price setting is the unit cost as a percentage of the sell price of that product. So if you sell a product for $18 each, entering “10” as the % of sell price would assign the cost to 10% of 18 which would be $1.80 for that product.
This value is combined with the static fee, which is just an absolute value for every unit sold, so if you set that value to 5, then the static fee would be $5 for every unit sold.
Therefore, the combined cost per unit would be $1.8 + $5.00 = $6.80 per unit.
2. Setup Product Specific Default Costs (Optional) – Product Edit Page
You can setup default product costs for each of your products as outlined in the image below from the single product edit page, although this is optional.
These will be the default values used for the order for this particular product where applicable and takes precedence over your global settings assigned from Alpha Insights > General Settings (for this particular product).
Currently, we do not support product variations but with enough request we will review this.
The same settings are available as per the global settings and you can get an estimated profit calculation from this page too.
Overriding Product Costs At The Order Level
Update Custom Product Costs At Line Item Level
If you have enabled the custom product costs correctly, you will see a few new fields on your WooCommerce order page.
Each line item will now have a new input field for each of the custom product costs that you setup.
By default it will use the value you have set at the product level, or the global settings from Alpha Insights > General Settings.
You can override these for each order by entering a number into the input and clicking Save & Recalculate or by updating the order.
You should see the updated value reflected in the input, in the line item summary (Alpha Insights COGS) and it should also update the total costs in the Alpha Insights Summary Dashboard.
Update Custom Product Costs Total For An Order
If you have any custom product costs enabled, there will also be a new input field in the Alpha Insights Summary Dashboard called “Total Product Custom Costs” in the cost overrides section.
By default, this is the sum of all the line item costs.
You can override this value if you would like, but this will totally ignore all line item inputs & assign the total custom product costs as the value you have set here.
(Optional) Create Complex Custom Product Cost Configurations Using PHP Filters
You can create more complex configurations that are product specific using the filter wpd_ai_custom_product_cost_options.
The example snippet below shows you how you can either customize configured custom product costs or assign new ones, using the product_id to offer more complex solutions.
The array key is the unique ID for this cost, so If you ever update the array key, it will reference a new custom cost and previous data will be irrelevant if set.
You can click here to read more about using this filter to create complex custom product cost options.
Example Snippet:
/**
*
* Add custom product cost inputs to the product page
*
* @param array The Custom product costs
* @param int The product ID to check against
*
**/
add_filter( 'wpd_ai_custom_product_cost_options', 'wpd_additional_product_cost_inputs', 10, 2 );
function wpd_additional_product_cost_inputs( $custom_product_costs, $product_id ) {
// Shipping
$custom_product_costs['shipping_costs'] = array(
'label' => 'Shipping Costs',
'description' => 'Shipping costs for each unit of this product sold.',
'placeholder' => '',
'static_fee' => 1,
'percent_of_sell_price' => 10 // Expects integer, we convert to a decimal later
);
// Modify a particular product
if ( $product_id == 36 ) $custom_product_costs['shipping_costs']['percent_of_sell_price'] = 5;
// Return results
return $custom_product_costs;
}