Which meta fields can I use from StoreLinkr in WooCommerce?
Please note: this article is intended for (theme) developers who work on a WordPress site.
In our StoreLinkr plugin, we use various meta fields to make all product information available in the WooCommerce shop.
Product variants – Variable product
There are options within a variable product. Each option is a separate product, also within StoreLinkr. At the variant option level, you can retrieve the following metafields:
| _product_attributes | An array of attributes (key, value) |
| _product_attachments | An array with attachments |
| stock_locations | An array with stock locations Single products |
Single products
There are also separate products, which we create as Single products. At the product level, you can retrieve the following metafields:
| _product_attributes | An array of attributes (key, value) |
| _product_attachments | An array with attachments |
| stock_locations | An array with stock locations Single products |
Example code for using a metafield
If you want to use a meta field as a developer, you can use the snippet below in your code:
<?php
$product = wc_get_product(3); // the id
$stock_locations = $product->get_meta(‘stock_locations’);
// Display a list of stock locations for this product
var_dump($stock_locations);