View Categories

Product Cost and Profit Shortcodes Reference

The product cost and profit shortcodes let you display a product’s cost or profit anywhere on your WooCommerce store. Cost of Goods: Product Cost & Profit Calculator for WooCommerce ships two shortcodes for this, and both are free. This is the full reference for their tags, attributes and defaults.

Shortcodes sub-tab showing [wpfcogs_product_profit] and [wpfcogs_product_cost] enable checkboxes

The two shortcodes #

  • [wpfcogs_product_cost]: shows a product’s cost. Useful in admin views or gated wholesale sections where cost transparency is wanted.
  • [wpfcogs_product_profit]: shows a product’s profit (price minus cost).

Enable them first. Both are off by default. Turn them on under WPFactory > Cost of Goods > Shortcodes (also reachable at WooCommerce > Settings > Cost of Goods > Shortcodes) before using them, or they output nothing.

Attributes #

Attribute Applies to Default Purpose
product_id Both Current product The product to read. If empty, the current product is used.
html_template Both <span class="wpfcogs-product-cost">{content}</span> / ...-product-profit... Wrapper HTML. {content} is replaced with the value.
profit_template [wpfcogs_product_profit] %profit% (%profit_percent%) The value format. Placeholders below.

Profit placeholders #

  • %profit%: the profit amount.
  • %profit_percent%: profit divided by cost, as a percentage.
  • %profit_margin%: profit divided by price, as a percentage.

Examples #

[wpfcogs_product_cost]
[wpfcogs_product_profit product_id="123"]
[wpfcogs_product_profit profit_template="%profit% (%profit_margin% margin)"]

Note on the old tags #

The previous names [alg_wc_cog_product_cost] and [alg_wc_cog_product_profit] were renamed in v4.1.6. They still resolve but now emit a deprecation notice, so use the wpfcogs_ tags in new work.

See also #

For a step-by-step walkthrough, see Show product cost and profit with shortcodes.

Get more from Cost of Goods #

These shortcodes are free. Cost of Goods: Product Cost & Profit Calculator for WooCommerce Pro adds cost and profit across WooCommerce Analytics, order emails and multicurrency stores. See what Pro unlocks.

 

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