How to Hide the WooCommerce 'Ticket' Category

Home Forums Ticket Products Event Tickets Plus How to Hide the WooCommerce 'Ticket' Category

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #45040
    digitalfusion
    Participant

    Is there a way to hide the WooCommerce ‘Ticket’ Category that the plugin creates and assigns Tickets to? Since Tickets are hidden by default, which we like, we’d like to hide the empty category from the Product Categories Widget and Listings.

    Thanks.

    #45063
    Barry
    Member

    Hi digitalfusion.

    You could try adding this snippet to your theme’s functions.php file. Do note that you will almost certainly have to change it slightly (instructions are in the comment block in the snippet) as the ID of the tickets category is almost certainly going to be different from my test installation 🙂

    Let me know if you have any difficulties.

    #45076
    digitalfusion
    Participant

    Hmm. That seems to work for the Product Categories widget, but not on the Shop page itself.

    #45088
    Barry
    Member

    I’m not exactly sure which references to the Tickets category you are referring to. I looked at the URL you provided when you opened the ticket and also the one below (I’ll share that as a private post in case you don’t want the URLs to be public) but was unable to identify the problem.

    #45089
    Barry
    Member

    This reply is private.

    #45090
    digitalfusion
    Participant

    I actually have another piece of code in there that seems to be doing the trick in both the widget and the shop pages. If I used the one you provided, it works for the widget, but the ticket category still shows up on the shop page. I can switch them out again if you’d like to see.

    This is the code I round elsewhere that seems to be working:

    add_filter( ‘get_terms’, ‘get_subcategory_terms’, 10, 3 );

    function get_subcategory_terms( $terms, $taxonomies, $args ) {
    $new_terms = array();

    // if a product category and on the shop page
    if ( in_array( ‘product_cat’, $taxonomies ) && ! is_admin()) {
    foreach ( $terms as $key => $term ) {
    if ( ! in_array( $term->slug, array( ‘ticket’ ) ) ) {
    $new_terms[] = $term;
    }
    }

    $terms = $new_terms;
    }

    return $terms;
    }

    #45091
    digitalfusion
    Participant

    This reply is private.

    #45103
    Barry
    Member

    OK, that explains why I couldn’t see the Tickets category then 🙂 Why not use both snippets?

    #45125
    digitalfusion
    Participant

    Actually, the one I posted above works in all cases, so for now, I suppose I’ll just use that one. Thanks for the help!

    #45166
    Barry
    Member

    No problem, thanks for reporting the fix that you found for this 🙂

    I’ll close this thread now since it seems we’re all sorted on this front.

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘How to Hide the WooCommerce 'Ticket' Category’ is closed to new replies.