Home › Forums › Ticket Products › Event Tickets Plus › Event Tickets Defaulting to "Ticket" Category on the WOO side
- This topic has 3 replies, 2 voices, and was last updated 8 years, 8 months ago by Barry.
-
AuthorPosts
-
September 1, 2015 at 2:56 pm #1001036Chris BlairParticipant
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?
September 2, 2015 at 7:11 am #1001252BarryMemberHi 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?
September 2, 2015 at 7:39 am #1001267Chris BlairParticipantThank you. Great Snippet
September 2, 2015 at 9:13 am #1001300BarryMemberHappy to help 🙂
-
AuthorPosts
- The topic ‘Event Tickets Defaulting to "Ticket" Category on the WOO side’ is closed to new replies.