{"id":1224,"date":"2013-09-19T07:57:38","date_gmt":"2013-09-19T07:57:38","guid":{"rendered":"http:\/\/www.websitedesignwebsitedevelopment.com\/?p=1224"},"modified":"2014-03-19T09:13:38","modified_gmt":"2014-03-19T09:13:38","slug":"woocommerce-get_item_meta","status":"publish","type":"post","link":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/plugins\/woocommerce-get_item_meta\/","title":{"rendered":"WooCommerce Version 2.0.12 &#8211; get_item_meta"},"content":{"rendered":"<h2>WooCommerce Version 2.0.12<\/h2>\n<p>File: classes\/class-wc-order.php<br \/>\nFunction: get_item_meta<br \/>\nIssue: It returns empty although itemdata table have records.<br \/>\nRef: <a href=\"http:\/\/wordpress.org\/support\/topic\/get_item_meta-returns-empty?replies=1#post-4320425\" rel=\"nofollow\">Support<\/a><\/p>\n<p>Suggested Fix: There is another function which is available in the same class with the name &#8220;has_meta&#8221;. We can use it as an else case.<\/p>\n<p>Insert the following code in function &#8220;get_items&#8221; after this line<br \/>\n<code>$items[ $item-&gt;order_item_id ]['item_meta'] = $this-&gt;get_item_meta( $item-&gt;order_item_id );<br \/>\nif(empty($items[ $item-&gt;order_item_id ]['item_meta'])){<br \/>\n$has_meta = $this-&gt;has_meta($item-&gt;order_item_id);<br \/>\nif(!empty($has_meta)){<br \/>\nforeach($has_meta as $imeta){<br \/>\n$items[$item-&gt;order_item_id]['item_meta'][$imeta['meta_key']]=array($imeta['meta_value']);<br \/>\n}<br \/>\n}<br \/>\n}<\/code><\/p>\n<p>Expected Output:<br \/>\n<code>Array<br \/>\n(<br \/>\n[3] =&gt; Array<br \/>\n(<br \/>\n[name] =&gt; Product Name<br \/>\n[type] =&gt; line_item<br \/>\n[item_meta] =&gt; Array<br \/>\n(<br \/>\n[_line_subtotal] =&gt; 168<br \/>\n[_line_subtotal_tax] =&gt; 0<br \/>\n[_line_tax] =&gt; 0<br \/>\n[_line_total] =&gt; 168<br \/>\n[_product_id] =&gt; 53<br \/>\n[_qty] =&gt; 1<br \/>\n[_tax_class] =&gt;<br \/>\n[_variation_id] =&gt;<br \/>\n)<br \/>\n[line_subtotal] =&gt; 168<br \/>\n[line_subtotal_tax] =&gt; 0<br \/>\n[line_tax] =&gt; 0<br \/>\n[line_total] =&gt; 168<br \/>\n[product_id] =&gt; 53<br \/>\n[qty] =&gt; 1<br \/>\n[tax_class] =&gt;<br \/>\n[variation_id] =&gt;<br \/>\n)<br \/>\n)<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>WooCommerce Version 2.0.12 File: classes\/class-wc-order.php Function: get_item_meta Issue: It returns empty although itemdata table have records. Ref: Support Suggested Fix: There is another function which is available in the same class with the name &#8220;has_meta&#8221;. We can use it as an else case. Insert the following code in function &#8220;get_items&#8221; after this line $items[ $item-&gt;order_item_id [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[65],"tags":[],"class_list":["post-1224","post","type-post","status-publish","format-standard","hentry","category-plugins"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>WooCommerce Version 2.0.10 - get_item_meta<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/plugins\/woocommerce-get_item_meta\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WooCommerce Version 2.0.10 - get_item_meta\" \/>\n<meta property=\"og:description\" content=\"WooCommerce Version 2.0.12 File: classes\/class-wc-order.php Function: get_item_meta Issue: It returns empty although itemdata table have records. Ref: Support Suggested Fix: There is another function which is available in the same class with the name &#8220;has_meta&#8221;. We can use it as an else case. Insert the following code in function &#8220;get_items&#8221; after this line $items[ $item-&gt;order_item_id [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/plugins\/woocommerce-get_item_meta\/\" \/>\n<meta property=\"og:site_name\" content=\"AndroidBubble Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/pages\/Website-Design-Website-Development\/172363336135453\" \/>\n<meta property=\"article:published_time\" content=\"2013-09-19T07:57:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-03-19T09:13:38+00:00\" \/>\n<meta name=\"author\" content=\"Fahad\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Fahad\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/plugins\/woocommerce-get_item_meta\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/plugins\/woocommerce-get_item_meta\/\"},\"author\":{\"name\":\"Fahad\",\"@id\":\"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7\"},\"headline\":\"WooCommerce Version 2.0.12 &#8211; get_item_meta\",\"datePublished\":\"2013-09-19T07:57:38+00:00\",\"dateModified\":\"2014-03-19T09:13:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/plugins\/woocommerce-get_item_meta\/\"},\"wordCount\":66,\"articleSection\":[\"Plugins\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/plugins\/woocommerce-get_item_meta\/\",\"url\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/plugins\/woocommerce-get_item_meta\/\",\"name\":\"WooCommerce Version 2.0.10 - get_item_meta\",\"isPartOf\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/#website\"},\"datePublished\":\"2013-09-19T07:57:38+00:00\",\"dateModified\":\"2014-03-19T09:13:38+00:00\",\"author\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7\"},\"breadcrumb\":{\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/plugins\/woocommerce-get_item_meta\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/plugins\/woocommerce-get_item_meta\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/plugins\/woocommerce-get_item_meta\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/androidbubble.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Website Development\",\"item\":\"https:\/\/androidbubble.com\/blog\/category\/website-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PHP Frameworks\",\"item\":\"https:\/\/androidbubble.com\/blog\/category\/website-development\/php-frameworks\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Wordpress\",\"item\":\"https:\/\/androidbubble.com\/blog\/category\/website-development\/php-frameworks\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Plugins\",\"item\":\"https:\/\/androidbubble.com\/blog\/category\/website-development\/php-frameworks\/wordpress\/plugins\/\"},{\"@type\":\"ListItem\",\"position\":6,\"name\":\"WooCommerce Version 2.0.12 &#8211; get_item_meta\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/androidbubble.com\/blog\/#website\",\"url\":\"https:\/\/androidbubble.com\/blog\/\",\"name\":\"AndroidBubble Blog\",\"description\":\"Articles &amp; Posts\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/androidbubble.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7\",\"name\":\"Fahad\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/afab5bcad71955d142a69df1758e6710aed4ab9cc2b5da28c54a7c3f39801b73?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/afab5bcad71955d142a69df1758e6710aed4ab9cc2b5da28c54a7c3f39801b73?s=96&d=mm&r=g\",\"caption\":\"Fahad\"},\"sameAs\":[\"http:\/\/www.androidbubbles.com\/\",\"https:\/\/x.com\/phpFlex\"],\"url\":\"https:\/\/androidbubble.com\/blog\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"WooCommerce Version 2.0.10 - get_item_meta","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/plugins\/woocommerce-get_item_meta\/","og_locale":"en_US","og_type":"article","og_title":"WooCommerce Version 2.0.10 - get_item_meta","og_description":"WooCommerce Version 2.0.12 File: classes\/class-wc-order.php Function: get_item_meta Issue: It returns empty although itemdata table have records. Ref: Support Suggested Fix: There is another function which is available in the same class with the name &#8220;has_meta&#8221;. We can use it as an else case. Insert the following code in function &#8220;get_items&#8221; after this line $items[ $item-&gt;order_item_id [&hellip;]","og_url":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/plugins\/woocommerce-get_item_meta\/","og_site_name":"AndroidBubble Blog","article_publisher":"https:\/\/www.facebook.com\/pages\/Website-Design-Website-Development\/172363336135453","article_published_time":"2013-09-19T07:57:38+00:00","article_modified_time":"2014-03-19T09:13:38+00:00","author":"Fahad","twitter_misc":{"Written by":"Fahad","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/plugins\/woocommerce-get_item_meta\/#article","isPartOf":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/plugins\/woocommerce-get_item_meta\/"},"author":{"name":"Fahad","@id":"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7"},"headline":"WooCommerce Version 2.0.12 &#8211; get_item_meta","datePublished":"2013-09-19T07:57:38+00:00","dateModified":"2014-03-19T09:13:38+00:00","mainEntityOfPage":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/plugins\/woocommerce-get_item_meta\/"},"wordCount":66,"articleSection":["Plugins"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/plugins\/woocommerce-get_item_meta\/","url":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/plugins\/woocommerce-get_item_meta\/","name":"WooCommerce Version 2.0.10 - get_item_meta","isPartOf":{"@id":"https:\/\/androidbubble.com\/blog\/#website"},"datePublished":"2013-09-19T07:57:38+00:00","dateModified":"2014-03-19T09:13:38+00:00","author":{"@id":"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7"},"breadcrumb":{"@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/plugins\/woocommerce-get_item_meta\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/plugins\/woocommerce-get_item_meta\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/androidbubble.com\/blog\/website-development\/php-frameworks\/wordpress\/plugins\/woocommerce-get_item_meta\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/androidbubble.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Website Development","item":"https:\/\/androidbubble.com\/blog\/category\/website-development\/"},{"@type":"ListItem","position":3,"name":"PHP Frameworks","item":"https:\/\/androidbubble.com\/blog\/category\/website-development\/php-frameworks\/"},{"@type":"ListItem","position":4,"name":"Wordpress","item":"https:\/\/androidbubble.com\/blog\/category\/website-development\/php-frameworks\/wordpress\/"},{"@type":"ListItem","position":5,"name":"Plugins","item":"https:\/\/androidbubble.com\/blog\/category\/website-development\/php-frameworks\/wordpress\/plugins\/"},{"@type":"ListItem","position":6,"name":"WooCommerce Version 2.0.12 &#8211; get_item_meta"}]},{"@type":"WebSite","@id":"https:\/\/androidbubble.com\/blog\/#website","url":"https:\/\/androidbubble.com\/blog\/","name":"AndroidBubble Blog","description":"Articles &amp; Posts","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/androidbubble.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/0a833b633f744c3a5e0de7c9a94e71f7","name":"Fahad","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/androidbubble.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/afab5bcad71955d142a69df1758e6710aed4ab9cc2b5da28c54a7c3f39801b73?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/afab5bcad71955d142a69df1758e6710aed4ab9cc2b5da28c54a7c3f39801b73?s=96&d=mm&r=g","caption":"Fahad"},"sameAs":["http:\/\/www.androidbubbles.com\/","https:\/\/x.com\/phpFlex"],"url":"https:\/\/androidbubble.com\/blog\/author\/admin\/"}]}},"views":831,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/posts\/1224","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/comments?post=1224"}],"version-history":[{"count":10,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/posts\/1224\/revisions"}],"predecessor-version":[{"id":1474,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/posts\/1224\/revisions\/1474"}],"wp:attachment":[{"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/media?parent=1224"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/categories?post=1224"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/androidbubble.com\/blog\/wp-json\/wp\/v2\/tags?post=1224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}