Event Tickets Defaulting to "Ticket" Category on the WOO side

Home Forums Ticket Products Event Tickets Plus Event Tickets Defaulting to "Ticket" Category on the WOO side

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1001036
    Chris Blair
    Participant

    When creating event tickets initially we noticed that they would default to the “ticket” category on the product side of WOO. Since we have a ton of triggers that use that category it was helpful. However this behavior has stopped since we added more then one product category to our store. We sell retail items as well.

    Is there a setting or a code snippet to get the Event ticket to always associate with the “Ticket” category in WOO?

    #1001252
    Barry
    Member

    Hi Chris,

    We actually dropped this behaviour in our 3.11 release, the reason being that for a lot of users it was causing confusion.

    As tickets have their product visibility set to hidden by default (ie, so they don’t display in the storefront) adding them to the “Tickets” category meant that where a list of product categories was displayed there would be an entry of “Tickets” but it led customers to what was effectively an empty page.

    We did add some hooks to make it easy for customers to re-implement this or similar customizations, though:

    • wootickets_after_create_ticket fires when a ticket is first created
    • wootickets_after_update_ticket fires if a ticket is subsequently update
    • wootickets_after_save_ticket fires on either occasion (update or creation)

    So, some code like this would give you a way of reinstating the behaviour:

    function categorize_new_tickets( $ticket_id ) {
        wp_set_object_terms( $ticket_id, 'Ticket', 'product_cat', true );
    }
    
    add_action( 'wootickets_after_create_ticket', 'categorize_new_tickets' );

    You might add this to your theme functions.php file or any other suitable place. Does that help?

    #1001267
    Chris Blair
    Participant

    Thank you. Great Snippet

    #1001300
    Barry
    Member

    Happy to help 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Event Tickets Defaulting to "Ticket" Category on the WOO side’ is closed to new replies.