1. Home
  2. Docs
  3. Cost of Goods Sold (COGS)...
  4. Pro Features
  5. Cost Calculation Expression

Cost Calculation Expression

This knowledge-based article explains the “Cost Calculation Expression” setting, a pro feature available in the Cost of Goods for WooCommerce plugin by WP Factory. This feature lets you control how the plugin calculates product costs when the cost field is empty.

Finding the Setting:

  1. Navigate to the WooCommerce settings tab in your WordPress dashboard.
  2. Click on the “Cost of Goods” sub-tab.
  3. Go to the “Product” tab.
  4. Locate the “Cost Calculation Expression” option.

Understanding Placeholders:

The “Cost Calculation Expression” setting utilizes placeholders to represent different cost values:

  • %stock_prev%: Represents the previous stock level.
  • %cost_prev%: Represents the previous cost value.
  • %stock%: Represents the current stock level.
  • %cost%: Represents the current cost value (if entered).
  • %stock_now%: Represents the current stock level (same as %stock%).

Empty Cost Field Behavior:

This setting determines how the plugin handles situations where the cost field for a product is left empty. You can choose from the following options:

  • Prevents calculation: Selecting this option will prevent the plugin from calculating any cost when the field is empty. No cost data will be displayed.
  • Uses last cost value from “Add stock” history: This option utilizes the most recent cost value entered when adding stock to the product.
  • Uses current cost: If a cost value is currently entered in the field, this option will use that value for calculations.
  • Prevents calculation (default): This is the default behavior. The plugin won’t calculate any cost if the field is empty.

Choosing the Right Option:

The best option for you depends on your specific workflow and how you manage product costs. Here’s a breakdown to help you decide:

  • Use “Uses last cost value from ‘Add stock’ history” if you primarily update costs when adding new stock and want those values reflected even if the cost field is empty.
  • Use “Uses current cost” if you typically keep the cost field updated and want the plugin to use that value for calculations.
  • Use “Prevents calculation” if you don’t want the plugin to calculate any cost when the field is empty and prefer to manage costs manually.

Additional Notes:

  • This is a pro feature of the Cost of Goods for WooCommerce plugin.
  • Ensure you have the pro version activated to access this setting.

By understanding the “Cost Calculation Expression” setting and its functionalities, you can effectively manage product costs within your WooCommerce store and ensure accurate calculations.


Cost of Goods Sold (COGS): Cost & Profit Calculator for WooCommerce