Gatemi Stock Valuation Developer Reference

The free edition's filters use the prefix gmsvf_, the full edition's gmsv_. Each pair does the same job.

Filters

gmsvf_unit_cost / gmsv_unit_cost

What one unit of a product costs, after the stored value has been read.

Argument Type
$cost float|null The stored cost (the variation's own, else the parent's), or null when none is recorded
$product_id int The product (the parent, for a variation)
$variation_id int The variation, or 0

Return null to mean "unknown" — the product is then counted as uncosted. Return a number to value it.

// Cost every product in the "consignment" category at 0: we hold it, but do not own it.
add_filter( 'gmsv_unit_cost', function ( $cost, $product_id ) {
	return has_term( 'consignment', 'product_cat', $product_id ) ? 0.0 : $cost;
}, 10, 2 );

gmsvf_batch / gmsv_batch

How many products (and, in the full edition, how many orders for the aging pass) one database read takes. Default 200.

gmsvf_ceiling / gmsv_ceiling

The most products a valuation walks. Default 20000. When the ceiling is reached the screen says the figures cover only the first of them.

gmsvf_valuation / gmsv_valuation

The finished valuation array before it is drawn. Keys: products, units, cost_value, retail_value, margin, margin_percent, uncosted, uncosted_units, uncosted_retail, out_of_stock, backordered, rows (the rows shown), rows_hidden, capped; the full edition adds all (every row, used by the CSV and the aging pass) and categories.

Each row has id, name, sku, quantity, cost (null when unknown), price, cost_value (null when unknown) and retail_value.

Full edition only

  • gmsv_settings — the merged settings array (statuses, rows, look_back).
  • gmsv_modules — the modules booted.
  • gmsv_license_api_url, gmsv_update_cache_ttl, gmsv_update_retry_ttl, gmsv_sync_cache_ttl — licence server address and cache lifetimes.

Actions — Full edition

  • gmsv_booted — after every module has booted; receives the plugin's container.

Storage

Where Key Holds
Product and variation meta _gmcg_cost Unit cost as a decimal string; absent means unknown
Option gmsv_settings statuses (array), rows (int), look_back (int days)
Option gmsv_license Licence state (full edition)

_gmcg_cost is the key Gatemi Profit Reports and Gatemi Cost of Goods own. Never write a 0 there to mean "unknown": delete the meta instead.

// Read a cost the way the plugin does: null when unknown.
$raw  = get_post_meta( $product_id, '_gmcg_cost', true );
$cost = is_numeric( trim( (string) $raw ) ) ? (float) $raw : null;

There are no tables, no order meta, no cron events and no storefront hooks.

Admin hooks the plugin uses

  • Cost field: woocommerce_product_options_pricing and woocommerce_variation_options_pricing; saved on woocommerce_process_product_meta and woocommerce_save_product_variation, behind the nonce field gmsvf_cost_nonce / gmsv_cost_nonce.
  • Products list column: manage_edit-product_columns / manage_product_posts_custom_column, column key gmsvf_cost / gmsv_cost.

CSV export — Full edition

wp-admin/admin.php?page=gmsv-stock-value&gmsv_export=1&_wpnonce=…, handled on admin_init before any output, for users with manage_woocommerce. Use the Download the whole list as CSV button rather than building the URL: the nonce is required. The file is UTF-8, one row per counted product, with every cell neutralised against formula injection.

Admin CSS classes

.gmsvf-figure / .gmsva-figure (each total), .gmsvf-no-cost / .gmsva-no-cost (Not set), .gmsvf-capped / .gmsva-capped (the ceiling line), and in the full edition .gmsva-tag (never sold) and .gmsva-export (the CSV button).

Shopping Cart
Scroll to Top