Skip to main content

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 KeyDescription
advised_priceThe manufacturer's suggested retail price (MSRP).
stock_locationsA serialized array or object containing stock levels per location.
usedProduct condition (0 = New, 1 = Used).
_positive_pointsA list of product pros/plus points.
_negative_pointsA 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 KeyDescription
advised_priceThe manufacturer's suggested retail price (MSRP).
stock_locationsStock levels per location.
usedProduct condition (0 = New, 1 = Used).
_positive_pointsProduct pros/plus points.
_negative_pointsProduct 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);
}
Pro Tip

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.