{"id":1367201,"date":"2017-10-21T10:30:06","date_gmt":"2017-10-21T17:30:06","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wc_productget_post_data-is-deprecated-since-version-3-0-use-get_post-instead\/"},"modified":"2017-10-21T10:30:06","modified_gmt":"2017-10-21T17:30:06","slug":"wc_productget_post_data-is-deprecated-since-version-3-0-use-get_post-instead","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wc_productget_post_data-is-deprecated-since-version-3-0-use-get_post-instead\/","title":{"rendered":"WC_Product::get_post_data is deprecated since version 3.0! Use get_post instead."},"content":{"rendered":"<p>Hi there,<\/p>\n<p>I have a function in functions.php that used to display the tickets description in the email notifications, but now I get the following error:<\/p>\n<blockquote><p>WC_Product::get_post_data is deprecated since version 3.0! Use get_post instead.<\/p><\/blockquote>\n<p>The function is:<\/p>\n<pre><code>function add_ticket_description( $order ) {\n\n  \t \tforeach($order-&gt;get_items() as $item) {\n  \t \t\t$ticket_id = $item[&#039;product_id&#039;];\n\t\t\t$product = new WC_Product( $ticket_id );\n  \t \t\t$product_data = $product-&gt;get_post_data();\n  \t \t\t$ticket_description = $product_data-&gt;post_excerpt;\n  \t \t\t$product_id = $product_data-&gt;id;\n  \t \t\t \n  \t \t\t$main_post_id = get_post_meta($ticket_id, &#039;_tribe_wooticket_for_event&#039;, true );\n  \t \t\t$venue_id = get_post_meta($main_post_id, &#039;_EventVenueID&#039;, true );\n  \t\t\t$venue_address = get_post_meta($venue_id, &#039;_VenueAddress&#039;, true );\n\t\t\t$venue_city = get_post_meta($venue_id, &#039;_VenueCity&#039;, true );\n\t\t\t$venue_phone = get_post_meta($venue_id, &#039;_VenuePhone&#039;, true );\n\n\t\t\tif ($ticket_description != &#039;&#039;){\n\t\t\t\techo &quot;&lt;br&gt;&lt;h2&gt;Course Details: &lt;\/h2&gt;&quot;.$ticket_description;\n\t\t\t\techo $venue_address.&quot;, &quot;.$venue_city;\n\t\t\t\techo&quot;&lt;br&gt;&quot;.$venue_phone;\n\t\t\t}\n  \t \t}\n\t\t\n}<\/code><\/pre>\n<p>I&#8217;ve updated the WooCommerce and Woo Tickets plugins to the latest version on my test site.  Is it possible to fix this function so it works?  By simply replacing <\/p>\n<pre><code>$product = new WC_Product( $ticket_id );\n$product_data = $product-&gt;get_post_data();<\/code><\/pre>\n<p>with <\/p>\n<pre><code>$product = new WC_Product( $ticket_id );\n$product_data = $product-&gt;post_data();<\/code><\/pre>\n<p>I get a fatal error, and the page loses the CSS styling:<\/p>\n<p>Fatal error: Call to undefined method WC_Product::post_data() in \/public_html\/test_site\/wp-content\/themes\/theme-name\/functions.php on line 229<\/p>\n<p>By the way, I&#8217;m using the plugin WooCommerce Email Test to test how the email notifications look.<\/p>\n<p>Thanks in advance!<br \/>\nCintia<\/p>\n","protected":false},"template":"","class_list":["post-1367201","topic","type-topic","status-closed","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>WC_Product::get_post_data is deprecated since version 3.0! Use get_post instead. -<\/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:\/\/theeventscalendar.com\/support\/forums\/topic\/wc_productget_post_data-is-deprecated-since-version-3-0-use-get_post-instead\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WC_Product::get_post_data is deprecated since version 3.0! Use get_post instead. -\" \/>\n<meta property=\"og:description\" content=\"Hi there, I have a function in functions.php that used to display the tickets description in the email notifications, but now I get the following error: WC_Product::get_post_data is deprecated since version 3.0! Use get_post instead. The function is: function add_ticket_description( $order ) { foreach($order-&gt;get_items() as $item) { $ticket_id = $item[&#039;product_id&#039;]; $product = new WC_Product( $ticket_id [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wc_productget_post_data-is-deprecated-since-version-3-0-use-get_post-instead\/\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wc_productget_post_data-is-deprecated-since-version-3-0-use-get_post-instead\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wc_productget_post_data-is-deprecated-since-version-3-0-use-get_post-instead\/\",\"name\":\"WC_Product::get_post_data is deprecated since version 3.0! Use get_post instead. -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2017-10-21T17:30:06+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wc_productget_post_data-is-deprecated-since-version-3-0-use-get_post-instead\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wc_productget_post_data-is-deprecated-since-version-3-0-use-get_post-instead\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wc_productget_post_data-is-deprecated-since-version-3-0-use-get_post-instead\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/theeventscalendar.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Topics\",\"item\":\"https:\/\/theeventscalendar.com\/support\/topics\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Ticket Products\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Event Tickets Plus\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/event-tickets-plus\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"WC_Product::get_post_data is deprecated since version 3.0! Use get_post instead.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\",\"url\":\"https:\/\/theeventscalendar.com\/support\/\",\"name\":\"\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"WC_Product::get_post_data is deprecated since version 3.0! Use get_post instead. -","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:\/\/theeventscalendar.com\/support\/forums\/topic\/wc_productget_post_data-is-deprecated-since-version-3-0-use-get_post-instead\/","og_locale":"en_US","og_type":"article","og_title":"WC_Product::get_post_data is deprecated since version 3.0! Use get_post instead. -","og_description":"Hi there, I have a function in functions.php that used to display the tickets description in the email notifications, but now I get the following error: WC_Product::get_post_data is deprecated since version 3.0! Use get_post instead. The function is: function add_ticket_description( $order ) { foreach($order-&gt;get_items() as $item) { $ticket_id = $item[&#039;product_id&#039;]; $product = new WC_Product( $ticket_id [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wc_productget_post_data-is-deprecated-since-version-3-0-use-get_post-instead\/","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wc_productget_post_data-is-deprecated-since-version-3-0-use-get_post-instead\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wc_productget_post_data-is-deprecated-since-version-3-0-use-get_post-instead\/","name":"WC_Product::get_post_data is deprecated since version 3.0! Use get_post instead. -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2017-10-21T17:30:06+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wc_productget_post_data-is-deprecated-since-version-3-0-use-get_post-instead\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/wc_productget_post_data-is-deprecated-since-version-3-0-use-get_post-instead\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/wc_productget_post_data-is-deprecated-since-version-3-0-use-get_post-instead\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/theeventscalendar.com\/support\/"},{"@type":"ListItem","position":2,"name":"Topics","item":"https:\/\/theeventscalendar.com\/support\/topics\/"},{"@type":"ListItem","position":3,"name":"Ticket Products","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/"},{"@type":"ListItem","position":4,"name":"Event Tickets Plus","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/event-tickets-plus\/"},{"@type":"ListItem","position":5,"name":"WC_Product::get_post_data is deprecated since version 3.0! Use get_post instead."}]},{"@type":"WebSite","@id":"https:\/\/theeventscalendar.com\/support\/#website","url":"https:\/\/theeventscalendar.com\/support\/","name":"","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1367201","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1367201\/revisions"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=1367201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}