{"id":951694,"date":"2015-03-29T09:56:05","date_gmt":"2015-03-29T16:56:05","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/admin-events-list-ticket-counts\/"},"modified":"2015-04-02T09:43:52","modified_gmt":"2015-04-02T16:43:52","slug":"admin-events-list-ticket-counts","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/admin-events-list-ticket-counts\/","title":{"rendered":"Admin events list: ticket counts"},"content":{"rendered":"<p>I added a few lines of code to create an additional column on the admin view events list page that shows the total number of tickets sold for each event. This is *very* necessary and it would be awesome if you could add it to the codebase (bc putting it in a separate plugin is going to balloon this tiny bit of code).<\/p>\n<p>HOWEVER, there is some weirdness with Filters. The stock WP filters work just fine (date, category, etc). But the Organizer filter breaks my ticket count. Somehow the way the queries are layered, my calls to get the tickets from event are scrambled. The event ID is getting turned into a completely different, random number? Again, with either No filters or with standard WordPress filters, it all works great. But once I add an Organizer filter, ticket counts go to Zero bc for some reason, when it gets to get_all_event_tickets that method receives an invalid event id (post id). Any ideas?<\/p>\n<p>Here&#8217;s the method I added in tickets.php that gets called from custom_columns where I&#8217;ve added a new TixCount column:<\/p>\n<pre><code>\/**\n * JER\n * Returns total for all non-virtual tix\n *\n * @param null $event\n *\n * @return int\n *\/\nfunction tribe_get_tix_count( $event = null ) {\n\t$count = 0;\n\tif ( null === ( $event = tribe_events_get_event( $event ) ) ) {\n\t\treturn 0;\n\t}\n\tforeach ( TribeEventsTickets::get_all_event_tickets( $event-&gt;ID ) as $ticket ) {\n\t\t$is_virtual = get_post_meta($ticket-&gt;ID, &#039;_virtual&#039;, true); \/\/&#039;yes&#039; or &#039;no&#039;\n\t\tif ( strcasecmp( &#039;yes&#039;, $is_virtual ) == 0 ) {\n\t\t\t\/\/\/don&#039;t care\n\t\t} else {\n\t\t\t$count += $ticket-&gt;qty_sold;\n\t\t}\n\t}\n\treturn $count;\n}<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-951694","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>Admin events list: ticket counts -<\/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\/admin-events-list-ticket-counts\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Admin events list: ticket counts -\" \/>\n<meta property=\"og:description\" content=\"I added a few lines of code to create an additional column on the admin view events list page that shows the total number of tickets sold for each event. This is *very* necessary and it would be awesome if you could add it to the codebase (bc putting it in a separate plugin is [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/admin-events-list-ticket-counts\/\" \/>\n<meta property=\"article:modified_time\" content=\"2015-04-02T16:43:52+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\/admin-events-list-ticket-counts\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/admin-events-list-ticket-counts\/\",\"name\":\"Admin events list: ticket counts -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2015-03-29T16:56:05+00:00\",\"dateModified\":\"2015-04-02T16:43:52+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/admin-events-list-ticket-counts\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/admin-events-list-ticket-counts\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/admin-events-list-ticket-counts\/#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\":\"Admin events list: ticket counts\"}]},{\"@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":"Admin events list: ticket counts -","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\/admin-events-list-ticket-counts\/","og_locale":"en_US","og_type":"article","og_title":"Admin events list: ticket counts -","og_description":"I added a few lines of code to create an additional column on the admin view events list page that shows the total number of tickets sold for each event. This is *very* necessary and it would be awesome if you could add it to the codebase (bc putting it in a separate plugin is [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/admin-events-list-ticket-counts\/","article_modified_time":"2015-04-02T16:43:52+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\/admin-events-list-ticket-counts\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/admin-events-list-ticket-counts\/","name":"Admin events list: ticket counts -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2015-03-29T16:56:05+00:00","dateModified":"2015-04-02T16:43:52+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/admin-events-list-ticket-counts\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/admin-events-list-ticket-counts\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/admin-events-list-ticket-counts\/#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":"Admin events list: ticket counts"}]},{"@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\/951694","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":1,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/951694\/revisions"}],"predecessor-version":[{"id":951754,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/951694\/revisions\/951754"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=951694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}