{"id":599,"date":"2018-02-13T09:01:42","date_gmt":"2018-02-13T08:01:42","guid":{"rendered":"https:\/\/demos.welaunch.io\/woocommerce-variations-table\/?post_type=faq&#038;p=599"},"modified":"2023-01-05T20:40:11","modified_gmt":"2023-01-05T19:40:11","slug":"modify-variations-table-data-fields","status":"publish","type":"faq","link":"https:\/\/www.welaunch.io\/en\/knowledge-base\/faq\/modify-variations-table-data-fields\/","title":{"rendered":"Modify the Variations Table Data Fields"},"content":{"rendered":"<p><strong>If you want to enable or disable specific product data for the variations table you can use the &#8220;woocommerce_variations_table_data&#8221; filter like below.<\/strong><\/p>\n<h1>Modify Existing Data<\/h1>\n<p>In this example for the product ID 565 it has no price (pr), no add to cart (ca) and no sku (sk). Instead we added Stock (st) and Dimensions.<\/p>\n<pre>function modify_variations_table_data($data) {\n\tglobal $product;\n\n\tif($product-&gt;get_id() == 565) {\n\t\tunset($data['enabled']['pr']);\n\t\tunset($data['enabled']['ca']);\n\t\tunset($data['enabled']['sk']);\n\t\t$data['enabled']['stock'] = 'Stock';\n\t\t$data['enabled']['dimensions'] = 'Dimensions';\n\t}\n    return $data;\n}\nadd_filter( 'woocommerce_variations_table_data', 'modify_variations_table_data', 10, 1 );<\/pre>\n<p>Reference of Variables:<\/p>\n<ul>\n<li>&#8216;im&#8217; =&gt; Image<\/li>\n<li>&#8216;sk&#8217; =&gt; SKU<\/li>\n<li>&#8216;pr&#8217; =&gt; Price<\/li>\n<li>&#8216;st&#8217; =&gt; Stock<\/li>\n<li>&#8216;at&#8217; =&gt; Attributes<\/li>\n<li>&#8216;ca&#8217; =&gt; Add to Cart<\/li>\n<li>&#8216;de&#8217; =&gt; Description<\/li>\n<li>&#8216;di&#8217; =&gt; Dimensions<\/li>\n<li>&#8216;we&#8217; =&gt; Weight<\/li>\n<\/ul>\n<h2>Add custom Post Meta Data<\/h2>\n<p>If you want to add custom post meta data you have to set the post meta key in the filter array key and the name in the value element. An example:<\/p>\n<pre>function add_post_meta_to_variation_table($data) {\n\tglobal $product;\n\n\t$data['enabled']['my_custom_post_meta_key'] = 'Meta Key Title';\n\n    return $data;\n}\nadd_filter( 'woocommerce_variations_table_data', 'add_post_meta_to_variation_table', 10, 1 );<\/pre>\n","protected":false},"author":1,"featured_media":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","product_cat":[],"class_list":["post-599","faq","type-faq","status-publish","hentry","faq_topics-variations-table-filter-hooks"],"_links":{"self":[{"href":"https:\/\/www.welaunch.io\/en\/wp-json\/wp\/v2\/faq\/599","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=599"}],"version-history":[{"count":4,"href":"https:\/\/www.welaunch.io\/en\/wp-json\/wp\/v2\/faq\/599\/revisions"}],"predecessor-version":[{"id":13796,"href":"https:\/\/www.welaunch.io\/en\/wp-json\/wp\/v2\/faq\/599\/revisions\/13796"}],"wp:attachment":[{"href":"https:\/\/www.welaunch.io\/en\/wp-json\/wp\/v2\/media?parent=599"}],"wp:term":[{"taxonomy":"product_cat","embeddable":true,"href":"https:\/\/www.welaunch.io\/en\/wp-json\/wp\/v2\/product_cat?post=599"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}