View Categories

Cost and Profit Missing on Orders From POS, API or Other Plugins

If orders from a POS, the REST API or another plugin show no cost or profit in Cost of Goods: Product Cost & Profit Calculator for WooCommerce, they skipped the calculation step. Go to WPFactory > Cost of Goods (also reachable at WooCommerce > Settings > Cost of Goods) > Advanced and turn on the Order item costs options.

Symptoms #

  • Orders placed on the website have cost and profit, but orders from a point of sale plugin, an import or a CRM sync show 0.
  • A discount added to an order afterwards, for example on a POS, is not reflected in the profit.
  • Custom fields from another plugin stop saving on the admin order edit screen while Cost of Goods is active.

Causes and fixes #

  1. The order was created without a calculation hook. Cost of Goods calculates an order when WooCommerce fires one of the hooks listed in Advanced > Order calculation hooks. By default all of them are selected: woocommerce_new_order, woocommerce_update_order, woocommerce_checkout_order_processed, woocommerce_store_api_checkout_order_processed, woocommerce_api_create_order, woocommerce_cli_create_order, kco_before_confirm_order, save_post_shop_order and woocommerce_process_shop_order_meta. Orders created through the WooCommerce REST API are covered too, because the plugin fires woocommerce_new_order for them. If someone removed hooks from this list, add them back and save.
  2. The other plugin creates orders in its own way. Some POS and sync plugins build the order without any of those hooks. Turn on the matching options under Advanced > Order item costs so empty costs are filled in later:
    • Auto fill empty order items costs on order update
    • Auto fill empty order items costs on order status change: useful when the POS marks the order completed.
    • Auto fill empty order items costs on new order item addition
    • Auto fill empty order items costs on order meta update: only triggers for meta keys that do not start with _alg_wc_cog_.

    These options only fill lines that have no cost yet. They never overwrite a cost that is already saved.

  3. The order changed after it was calculated. If a discount or price change is applied after the order was created, the saved profit is not refreshed on its own. Open the order in the admin and click Update: saving the order recalculates its cost and profit. For many orders, use the Pro Orders recalculation tool on the Tools sub-tab. See Cost and Profit Show Zero or Outdated on Existing Orders.
  4. Calculations are delayed on purpose. If Orders > Calculations > Delay calculations lists order statuses, cost and profit stay at zero until the order reaches one of them. POS orders that skip those statuses never get values. Clear the field, or add the status your POS uses.
  5. Another plugin’s order fields stop saving. If custom order fields added by another plugin revert when you save an order, and the problem goes away when Cost of Goods is deactivated, remove woocommerce_process_shop_order_meta from Advanced > Order calculation hooks and test again. Saving an order still recalculates costs through woocommerce_update_order and save_post_shop_order. Tell our support team if this fixes it, so we can look at the conflict.

How to confirm it is fixed #

  1. Create a test order with the POS or tool that caused the problem, using a product that has a cost.
  2. Open the order in the admin and check the Cost of Goods meta box: cost and profit should be filled in.
  3. For orders created before the fix, run Recalculate no cost orders on the Tools sub-tab (Pro), or open and update each order.

FAQ #

Where are the cost and profit stored on the order? #

Order totals are saved as order meta, for example _alg_wc_cog_order_cost and _alg_wc_cog_order_profit, and each line’s cost as _alg_wc_cog_item_cost. A CRM or export tool can read these keys once the order has been calculated. See Cost of Goods: Developer Hooks and Filters Reference.

Are these options free? #

Yes. Order calculation hooks, the Order item costs auto fill options and Delay calculations are free. Only the bulk Orders recalculation tool is Pro.

Still stuck? #

Tell us which plugin creates the orders and send an example order. Our team answers every ticket on the Cost of Goods support forum.