In our WooCommerce Multi Inventory plugin the stock and price information per product is saved in custom meta fields called:
woocommerce_multi_inventory_inventories_stock
woocommerce_multi_inventory_prices
The data saved is a serialized array consisting of the inventory id <> inventory stock amount.
An example:
array( 21 => 10,
23 => 20, );
21 is the inventory ID and 10 the stock amount.
When importing this for example you have to use this function:
$product->update_meta_data( 'woocommerce_multi_inventory_inventories_stock', $productInventoriesStock);
Then you also need to make sure the inventory terms are set:
$terms = array_keys( array_filter( $productInventoriesStock) );
wp_set_post_terms($productId, $terms, 'inventories');
And the Total stock is updated (this is the sum of all frontend inventory stocks):
$product->set_stock_quantity($newTotalFrontendStock);
Hello
Is there way to show that product stock quantities meta field in products metafields?
So that when I export woocommerce products for example so that I could see the multi inventory meta fields on that export?