StockTrack for WooCommerce exposes context-aware virtual meta fields that allow other plugins, custom code, and integrations to access the correct product location — without needing to know StockTrack’s internal storage structure.
This makes it easy to reuse StockTrack location data across:
- Pick lists & fulfillment tools
- Custom admin views
- Reports & exports
- Third-party integrations
- Custom themes or plugins
Available virtual meta keys
StockTrack provides the following virtual product meta keys:
| Meta key | Description |
|---|---|
_wst_location_id | The resolved StockTrack location ID |
_wst_location_code | Human-readable location code (e.g. A-02-S3) |
⚠️ These meta keys are not stored directly on the product.
They are resolved dynamically based on context.
How the context resolution works
When another plugin or custom code requests one of the meta keys above, StockTrack determines which location is relevant at runtime.
Context priority (important)
StockTrack resolves the location in this order:
- Order fulfillment context
If the product is being accessed as part of an order (e.g. Pick List, fulfillment view), StockTrack returns the location assigned for that order. - Current admin location (StockTrack UI)
If the user is viewing or editing products inside StockTrack with a selected location, that location is used. - Fallback
If no location context can be determined,nullis returned.
This ensures that the same product can correctly resolve to different locations depending on usage, without duplicating logic elsewhere.
Why this matters
Without this approach, integrations would need to:
- Know which
_wst_location_id_{X}meta key to read - Manually resolve the “active” warehouse or fulfillment location
- Duplicate StockTrack logic
With virtual meta, integrations can simply ask for:
get_post_meta( $product_id, '_wst_location_code', true );
…and StockTrack handles the rest.
Example: Using location meta in custom code
Get resolved location ID
$location_id = get_post_meta( $product_id, '_wst_location_id', true );
if ( $location_id ) {
// Use location ID
}
Get resolved location code
$location_code = get_post_meta( $product_id, '_wst_location_code', true );
if ( $location_code ) {
echo esc_html( $location_code );
}
These calls are safe and will:
- Return the correct location when context exists
- Return
nullwhen no location applies
Integration notes & limitations
StockTrack exposes context-aware virtual meta fields that can be consumed by other plugins and custom integrations.
REST API
Virtual meta is not resolved for REST API requests by default.
If you are building REST-based integrations and need location data, you should:
- Resolve locations explicitly
- Or store/export location data per location where required
This avoids ambiguity and unintended side effects in API responses.
Storage model (advanced)
Internally, StockTrack stores location assignments per location using keys like:
_wst_location_id_{location_id}
The virtual meta layer exists specifically to:
- Abstract this structure
- Provide a stable API for integrations
- Allow StockTrack to evolve internally without breaking third-party code
Do not rely directly on internal meta keys unless you know exactly what you are doing.
Pick List for WooCommerce integration
Pick List for WooCommerce can display StockTrack location data by selecting StockTrack fields as custom product fields in Pick List settings.
Supported fields:
_wst_location_id_wst_location_code
Pick List simply renders the resolved value returned by StockTrack. It does not implement its own location logic or storage.
All location resolution is handled entirely by StockTrack.
StockTrack’s integration layer is designed to support more advanced visualization and workflow features in the future.
Best practices for developers
✔ Use _wst_location_id and _wst_location_code
✔ Let StockTrack handle context resolution
✔ Expect null when no location applies
✖ Do not hardcode internal meta keys
✖ Do not assume a single global location per product
Summary
StockTrack’s virtual location meta provides:
- Clean integration points
- Context-aware behavior
- Forward compatibility
- Zero duplication of business logic
If you are building plugins or custom solutions on top of StockTrack, this is the recommended way to access product locations.