Automatically assign event tickets to a product category?

Home Forums Ticket Products Event Tickets Plus Automatically assign event tickets to a product category?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1315510
    Andy
    Participant

    Can tickets created through event tickets pro be automatically assigned a specific woocommerce product category?

    #1316020
    Victor
    Member

    Hi Andy!

    Thanks for reaching out to us! I’d be happy to help here! 🙂

    There is no default option to do that. However, you could achieve something like that with some custom coding.

    The following is a code snippet that will assign the product category “movie-tickets” to all the tickets you create:

    add_action( 'event_tickets_after_save_ticket', 'tribe_events_add_product_category_to_tickets', 10, 4 );
    
    function tribe_events_add_product_category_to_tickets( $event_id, $ticket, $raw_data, $classname ) {
    
    if ( ! empty( $ticket ) && isset( $ticket->ID ) ) {
    wp_add_object_terms( $ticket->ID, 'movie-tickets', 'product_cat' );
    }
    }
    

    You can put that code in your theme’s functions.php file. Remember to change ‘movie-tickets’ for the category name of your choice.

    I hope that helps! Let me know if you have other questions.

    Best,
    Victor

    #1316385
    Andy
    Participant

    Great, thanks for the snippet!

    #1316620
    Victor
    Member

    You are welcome Andy! 🙂

    I’ll go ahead and close this, but feel free to open a new topic if you have any other questions.

    Cheers!
    Victor

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Automatically assign event tickets to a product category?’ is closed to new replies.