Available Metafields in WooCommerce
StoreLinkr synchronizes a wide range of product data to WooCommerce using standard WordPress post meta (metafields). Developers can use these fields to build custom frontend displays or integrate with other plugins.
Product Variants (Variations)
Each variation in WooCommerce is linked to a specific article in StoreLinkr. The following metafields are available at the variation level:
| Meta Key | Description |
|---|---|
advised_price | The manufacturer's suggested retail price (MSRP). |
stock_locations | A serialized array or object containing stock levels per location. |
used | Product condition (0 = New, 1 = Used). |
_positive_points | A list of product pros/plus points. |
_negative_points | A list of product cons/minus points. |
Single Products
For standard products (not part of a variable set), these metafields are stored directly on the main product post:
| Meta Key | Description |
|---|---|
advised_price | The manufacturer's suggested retail price (MSRP). |
stock_locations | Stock levels per location. |
used | Product condition (0 = New, 1 = Used). |
_positive_points | Product pros/plus points. |
_negative_points | Product cons/minus points. |
Usage Examples
To retrieve and use a metafield in your theme or plugin, use the standard WooCommerce or WordPress functions.
Retrieving Stock Locations
<?php
$product = wc_get_product($product_id);
$stock_locations = $product->get_meta('stock_locations');
if (!empty($stock_locations)) {
foreach ($stock_locations as $location) {
echo esc_html($location['name']) . ': ' . intval($location['stock']) . '<br>';
}
}
Displaying the Advised Price
<?php
$advised_price = get_post_meta($product->get_id(), 'advised_price', true);
if ($advised_price) {
echo 'MSRP: ' . wc_price($advised_price);
}
When working with variable products, remember that "Single Product" metafields are stored on the parent product, while variation-specific data is stored on the individual variation IDs.