Event Ticket Plus tags not goings to Woocommerce

Home Forums Ticket Products Event Tickets Plus Event Ticket Plus tags not goings to Woocommerce

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #1147511
    Melanie Adcock
    Participant

    I posted a question last month on an easy way to remove past event tickets from Woocommerce. Geoff B. suggested using categories or tags. I should of realized back then that I had to use a custom function to pass the category of “Ticket” to woocommerce that it would be the same for tags. My client teaches CPR classes and will be posting classes each month (6 classes per week). I would like to make it easy for him to delete old past event products. Selecting by tags he could quickly delete old classes once the month is past. Is there a custom function to pass tags to woocommerce from the event ticket?

    #1147875
    Andras
    Keymaster

    Hello Jonahgirl,

    Thanks for reaching out! Let me try to help you with your challenge.

    I understand what you are trying to do. However, I don’t quite understand this part: pass the category of โ€œTicketโ€ to WooCommerce.

    Tickets created with Event Tickets Plus do not have categories, only Events do. Is that what you would like to pass on to be a tag for the woo product?

    Another idea on removing old tickets: if you go to your Products then you see a published date for each ticket. If the client is posting classes each month one month in advance, then the July tickets will be published in June, so after July has passed all tickets published in June can be deleted.

    Let me know if this helps, and if you clarify the above for me, then I’ll try to get a solution for you.

    Cheers,
    Andras

     

    #1147925
    Melanie Adcock
    Participant

    I used a custom function to pass the category of Ticket to Woocommerce for each event. The reason being my client also sells tangible goods. This way I can have the classes not show as products in his store. I used the following function to add a category to woocommerce event product:

    add_filter( ‘wootickets_after_save_ticket’, ‘tribe_add_category_to_woocommerce_tickets’ );
    function tribe_add_category_to_woocommerce_tickets( $event_id ) {

    wp_set_object_terms( $event_id, ‘Ticket’, ‘product_cat’, true );

    }
    I need to make it obviously easy for my client to go in and delete passed products. Yes, I would look at the dates but who knows how often he will add them. Since the classes are always Wednesday, Thursday, and Saturday he may do a few months at a time. Sending the Tag to woocommerce would allow him to eliminate the past month easily.

    Melanie

    #1148031
    Andras
    Keymaster

    Hello Melanie,

    I hear you!

    There has been some changes in our plugins, as well as the WooCommerce plugin. Please give me some time so I can look into this. Thanks for your patience in advance!

    Andras

    #1148157
    Andras
    Keymaster

    Hi Melanie,

    Got some good news for you. One of my colleagues looked at the code and found a solution. Just paste this snippet in your functions.php file, and remove the old bit.

    add_action( ‘wootickets_after_save_ticket’, ‘tribe_add_category_to_woocommerce_tickets’ );
    function tribe_add_category_to_woocommerce_tickets( $event_id ) {

    wp_set_object_terms( $event_id, ‘Ticket’, ‘product_cat’, true );

    }

    Now when a WooCommerce ticket is saved, then in WooCommerce products it will have the category ‘Ticket’ assigned to it.

    Let me know if this helps.

    Cheers,
    Andras

    #1151632
    Melanie Adcock
    Participant

    Andras,
    Not good news. I already have the category of Ticket going to Woocommerce. I posted the exact same code in my second post on this thread. I need Tags to be sent to Woocommerce hence the title of this thread. I can create a Tag for each month. And add the appropriate tag for each month. When the month is over my client can simply delete all events with the tag of the previous month.

    #1152313
    Andras
    Keymaster

    Hi Melanie,

    Please hang in there, I’m working on this.

    Cheers,
    Andras

    #1152320
    Melanie Adcock
    Participant

    No worries. I have plenty of other stuff to work on.

    #1152831
    Andras
    Keymaster

    Hey Melanie,

    Thanks for your patience! I team mate took a look at it and came up with this snippet, that works as you would like it. When a ticket is created for an event, then the event’s tag is also added to the WooCommerce product ticket.

    Just paste this snippet into your functions.php file.


    /* Tribe port event tags as product tags for woo tickets */
    function tribe_add_tag_to_woocommerce_tickets($ticket_id, $event_id, $raw_data ) {

    // get event 'post_tags'
    $event_tags = wp_get_object_terms( $event_id, 'post_tag', array('fields' => 'names' ) );

    // bail if no 'post_tags' for event
    if ( empty( $event_tags ) || is_wp_error( $event_tags ) ) return false;

    // set event 'post_tags' as product 'product_tags'
    wp_set_object_terms( $ticket_id, $event_tags, 'product_tag', true );
    }
    add_action( 'wootickets_after_save_ticket', 'tribe_add_tag_to_woocommerce_tickets', 10, 3 );

    Please let me know how that works out for you.

    Cheers,
    Andras

    #1152834
    Melanie Adcock
    Participant

    AWESOME! This totally rocks! I actually think I am going to get this site live in the next couple of weeks. He is testing everything now (finally). I’ll upload and test and let you know.

    Melanie

    #1153372
    Andras
    Keymaster

    Hey Melanie,

    I’m super stoked to hear that works and that you are launching soon! I know just how exciting that is. ๐Ÿ™‚

    Please, do let me know how it works and would be great if you shared the site with us once it’s launched.

    Cheers,
    Andras

    #1153381
    Melanie Adcock
    Participant

    Doesn’t work. Oh well thanks for trying. I appreciate the effort.

    #1153431
    Andras
    Keymaster

    Hmmm… interesting. 2 of us tested it here and it works for us with these steps:

    1. Create an event with a tag.
    2. Publish the event. (So that the event gets an id and the tag gets saved in the taxonomies.)
    3. Add a WooCommerce ticket
    4. Check in WooCommerce Products whether the created ticket appears and it has the tag of the event.

    Did you use these steps?

    If you add the ticket before the event is published with a tag, then the tag will not transfer over to the ticket.

    Andras

    #1153602
    Melanie Adcock
    Participant

    Ah no, that is one process I didn’t try. And YES! it worked! Thank you!

    #1153851
    Andras
    Keymaster

    Great, I’m super stoked it helped! Woohoooo!!! ๐Ÿ™‚

    I am going to go ahead and close this ticket, but if you need help on this or something else, don’t hesitate to open a new one, we’ll be here to help you out.

    Cheers,
    Andras

Viewing 15 posts - 1 through 15 (of 15 total)
  • The topic ‘Event Ticket Plus tags not goings to Woocommerce’ is closed to new replies.