{"id":12050,"date":"2022-06-10T22:59:57","date_gmt":"2022-06-10T20:59:57","guid":{"rendered":"https:\/\/www.welaunch.io\/en\/?post_type=faq&#038;p=12050"},"modified":"2022-12-22T18:27:48","modified_gmt":"2022-12-22T17:27:48","slug":"where-is-multi-inventory-stock-data-saved","status":"publish","type":"faq","link":"https:\/\/www.welaunch.io\/en\/knowledge-base\/faq\/where-is-multi-inventory-stock-data-saved\/","title":{"rendered":"Where is Multi Inventory Stock Data Saved?"},"content":{"rendered":"<p>In our WooCommerce Multi Inventory plugin the stock and price information per product is saved in custom meta fields called:<\/p>\n<pre>woocommerce_multi_inventory_inventories_stock<br \/>woocommerce_multi_inventory_prices<\/pre>\n<p>The data saved is a serialized array consisting of the inventory id &lt;&gt; inventory stock amount.<\/p>\n<p>An example:<\/p>\n<pre>array(\n    21 =&gt; 10,<br \/>    23 =&gt; 20,\n);\n<\/pre>\n<p>21 is the inventory ID and 10 the stock amount.<\/p>\n<p>When importing this for example you have to use this function:<\/p>\n<pre>$product-&gt;update_meta_data( 'woocommerce_multi_inventory_inventories_stock', $productInventoriesStock);\n<\/pre>\n<p>Then you also need to make sure the inventory terms are set:<\/p>\n<pre>$terms = array_keys( array_filter( $productInventoriesStock) );<br \/>wp_set_post_terms($productId, $terms, 'inventories');\n<\/pre>\n<p>And the Total stock is updated (this is the sum of all frontend inventory stocks):<\/p>\n<pre>$product-&gt;set_stock_quantity($newTotalFrontendStock);<\/pre>\n","protected":false},"author":1,"featured_media":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","product_cat":[],"class_list":["post-12050","faq","type-faq","status-publish","hentry","faq_topics-multi-inventory"],"_links":{"self":[{"href":"https:\/\/www.welaunch.io\/en\/wp-json\/wp\/v2\/faq\/12050","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.welaunch.io\/en\/wp-json\/wp\/v2\/faq"}],"about":[{"href":"https:\/\/www.welaunch.io\/en\/wp-json\/wp\/v2\/types\/faq"}],"author":[{"embeddable":true,"href":"https:\/\/www.welaunch.io\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.welaunch.io\/en\/wp-json\/wp\/v2\/comments?post=12050"}],"version-history":[{"count":3,"href":"https:\/\/www.welaunch.io\/en\/wp-json\/wp\/v2\/faq\/12050\/revisions"}],"predecessor-version":[{"id":13680,"href":"https:\/\/www.welaunch.io\/en\/wp-json\/wp\/v2\/faq\/12050\/revisions\/13680"}],"wp:attachment":[{"href":"https:\/\/www.welaunch.io\/en\/wp-json\/wp\/v2\/media?parent=12050"}],"wp:term":[{"taxonomy":"product_cat","embeddable":true,"href":"https:\/\/www.welaunch.io\/en\/wp-json\/wp\/v2\/product_cat?post=12050"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}