Home › Forums › Ticket Products › Event Tickets Plus › Event Ticket Plus tags not goings to Woocommerce
- This topic has 15 replies, 3 voices, and was last updated 9 years, 8 months ago by
Melanie Adcock.
-
AuthorPosts
-
August 4, 2016 at 6:28 am #1147511
Melanie Adcock
ParticipantI 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?
August 4, 2016 at 4:00 pm #1147875Andras
KeymasterHello 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,
AndrasAugust 4, 2016 at 6:51 pm #1147925Melanie Adcock
ParticipantI 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
August 5, 2016 at 2:55 am #1148031Andras
KeymasterHello 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
August 5, 2016 at 7:58 am #1148157Andras
KeymasterHi 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,
AndrasAugust 15, 2016 at 7:18 am #1151632Melanie Adcock
ParticipantAndras,
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.August 16, 2016 at 2:02 pm #1152313Andras
KeymasterHi Melanie,
Please hang in there, I’m working on this.
Cheers,
AndrasAugust 16, 2016 at 2:18 pm #1152320Melanie Adcock
ParticipantNo worries. I have plenty of other stuff to work on.
August 17, 2016 at 2:20 pm #1152831Andras
KeymasterHey 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,
AndrasAugust 17, 2016 at 2:25 pm #1152834Melanie Adcock
ParticipantAWESOME! 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
August 18, 2016 at 2:29 pm #1153372Andras
KeymasterHey 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,
AndrasAugust 18, 2016 at 2:41 pm #1153381Melanie Adcock
ParticipantDoesn’t work. Oh well thanks for trying. I appreciate the effort.
August 18, 2016 at 4:05 pm #1153431Andras
KeymasterHmmm… interesting. 2 of us tested it here and it works for us with these steps:
- Create an event with a tag.
- Publish the event. (So that the event gets an id and the tag gets saved in the taxonomies.)
- Add a WooCommerce ticket
- 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
August 19, 2016 at 7:53 am #1153602Melanie Adcock
ParticipantAh no, that is one process I didn’t try. And YES! it worked! Thank you!
August 19, 2016 at 2:10 pm #1153851Andras
KeymasterGreat, 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 -
AuthorPosts
- The topic ‘Event Ticket Plus tags not goings to Woocommerce’ is closed to new replies.
