{"id":1028401,"date":"2015-11-20T02:58:47","date_gmt":"2015-11-20T10:58:47","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/displaying-remaining-stock-in-related-events\/"},"modified":"2015-11-24T16:42:05","modified_gmt":"2015-11-25T00:42:05","slug":"displaying-remaining-stock-in-related-events","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/displaying-remaining-stock-in-related-events\/","title":{"rendered":"Displaying remaining stock in related events"},"content":{"rendered":"<p>Hi &#8211; using the following function found on here I&#8217;m wanting to output the remaining stock level into the &#8216;Related Events&#8217; section at the bottom of each single event page. I&#8217;ve tried modifying as it as standard just outputs the stock level of the current product page onto each related event.<\/p>\n<p>However it doesn&#8217;t work &#8211; Closest I can get is a list of all ticket stock! Any guidance would be much appreciated&#8230;<\/p>\n<p>function displaying_stock_information() {<\/p>\n<p>`$post_id = get_the_id();<br \/>\nif ( Tribe__Events__Main::POSTTYPE !== get_post_type( $post_id ) ) {<br \/>\nreturn;<br \/>\n}<br \/>\n$Woo__Tickets = Tribe__Events__Tickets__Woo__Main::get_instance();<br \/>\n$ticket_ids = $Woo__Tickets-&gt;get_tickets_ids( $post_id );<\/p>\n<p>if ( is_array( $ticket_ids ) ) {<\/p>\n<p>foreach ( $ticket_ids as $ticket_id ) {<br \/>\n$ticket = $Woo__Tickets-&gt;get_ticket( $post_id, $ticket_id );<br \/>\n$html .= sprintf( &#8216;&lt;dt&gt;<strong>Places available:<\/strong>&lt;\/dt&gt;&lt;dd&gt;%s&lt;\/dd&gt;&#8217;, $ticket-&gt;stock );<br \/>\n\/\/ to show ticket name also: $html .= sprintf( &#8216;<\/p>\n<ul>\n<li><strong>%s<\/strong> tickets remaining: %s<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&#8216;, $ticket-&gt;name, $ticket-&gt;stock );<br \/>\n}<\/p>\n<p>if ( $ticket-&gt;stock &gt; 0 ) { \/\/ if all tickets sold or no tickets<br \/>\necho $html;<br \/>\n} else {<br \/>\necho &#8216;&lt;dt&gt;<strong>Places available:<\/strong>&lt;\/dt&gt;&lt;dd&gt;<strong>COURSE SOLD OUT<\/strong>&lt;\/dd&gt;&#8217;;<br \/>\n}<br \/>\n}<\/p>\n<p>}`<\/p>\n","protected":false},"template":"","class_list":["post-1028401","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>Displaying remaining stock in related events -<\/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\/displaying-remaining-stock-in-related-events\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Displaying remaining stock in related events -\" \/>\n<meta property=\"og:description\" content=\"Hi &#8211; using the following function found on here I&#8217;m wanting to output the remaining stock level into the &#8216;Related Events&#8217; section at the bottom of each single event page. I&#8217;ve tried modifying as it as standard just outputs the stock level of the current product page onto each related event. However it doesn&#8217;t work [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/displaying-remaining-stock-in-related-events\/\" \/>\n<meta property=\"article:modified_time\" content=\"2015-11-25T00:42:05+00:00\" \/>\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\/displaying-remaining-stock-in-related-events\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/displaying-remaining-stock-in-related-events\/\",\"name\":\"Displaying remaining stock in related events -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2015-11-20T10:58:47+00:00\",\"dateModified\":\"2015-11-25T00:42:05+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/displaying-remaining-stock-in-related-events\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/displaying-remaining-stock-in-related-events\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/displaying-remaining-stock-in-related-events\/#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\":\"Displaying remaining stock in related events\"}]},{\"@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":"Displaying remaining stock in related events -","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\/displaying-remaining-stock-in-related-events\/","og_locale":"en_US","og_type":"article","og_title":"Displaying remaining stock in related events -","og_description":"Hi &#8211; using the following function found on here I&#8217;m wanting to output the remaining stock level into the &#8216;Related Events&#8217; section at the bottom of each single event page. I&#8217;ve tried modifying as it as standard just outputs the stock level of the current product page onto each related event. However it doesn&#8217;t work [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/displaying-remaining-stock-in-related-events\/","article_modified_time":"2015-11-25T00:42:05+00:00","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\/displaying-remaining-stock-in-related-events\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/displaying-remaining-stock-in-related-events\/","name":"Displaying remaining stock in related events -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2015-11-20T10:58:47+00:00","dateModified":"2015-11-25T00:42:05+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/displaying-remaining-stock-in-related-events\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/displaying-remaining-stock-in-related-events\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/displaying-remaining-stock-in-related-events\/#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":"Displaying remaining stock in related events"}]},{"@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\/1028401","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":2,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1028401\/revisions"}],"predecessor-version":[{"id":1030436,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1028401\/revisions\/1030436"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=1028401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}