Home › Forums › Ticket Products › Event Tickets Plus › This is the MySQL code to delete tickets
- This topic has 6 replies, 3 voices, and was last updated 10 years, 9 months ago by
Support Droid.
-
AuthorPosts
-
July 18, 2013 at 9:35 am #55888
buooy
ParticipantHi All,
I realised that a lot of people are asking how to delete the tickets.
Just find and replace all instances of 886 with ur ticket id.For the developers, I already provided the code? haha. If you could do us all a favour and implement it into a simple “delete” link on each ticket in the attendees list or provide it as a function for the checkboxes, it would be uber duper awesome…
Hope it helps everyone.
So if you are a developer or a mini DBA, here is the MySQL code (For the the ugly):
# Finds the product associated with the ticket
# Updates the total sales by reducing by 1
UPDATE events_postmeta
INNER JOIN (SELECT meta_value FROM events_postmeta
WHERE post_id = ‘886’
AND meta_key = ‘_tribe_wooticket_product’)
AS ticket_number
ON ticket_number.meta_value = events_postmeta.post_id
SET events_postmeta.meta_value = events_postmeta.meta_value -1
WHERE events_postmeta.meta_key = ‘total_sales’;# Finds the product associated with the ticket
# Updates the _stock by increasing it by 1
UPDATE events_postmeta
INNER JOIN (SELECT meta_value FROM events_postmeta
WHERE post_id = ‘886’
AND meta_key = ‘_tribe_wooticket_product’)
AS ticket_number
ON ticket_number.meta_value = events_postmeta.post_id
SET events_postmeta.meta_value = events_postmeta.meta_value + 1
WHERE events_postmeta.meta_key = ‘_stock’;# Delete the ticket details
DELETE events_postmeta FROM events_postmeta
WHERE post_id = ‘886’;# Delete the ticket
DELETE events_posts FROM events_posts
WHERE ID = ‘886’;July 18, 2013 at 10:21 am #55901Barry
MemberThanks for sharing!
As a general note to all, remember also that tickets (the products themselves) can be removed with the delete link.
Additionally, if an order for tickets needs to be cancelled or refunded then this can be accomplished by editing the order via WooCommerce – the new status will then be reflected in the attendee’s list.
July 18, 2013 at 10:24 am #55902buooy
ParticipantThe new status will be reflected. HOWEVER, the total sales and the quantity remaining will not be changed. Meaning that I could have one ticket hanging loose.
It is also not reflected on the summary portion.
If it cost $500, i could potentially be missing out on $500.
July 18, 2013 at 11:43 am #55919buooy
ParticipantTo add on, if you ever need to “upgrade” your attendees, please use the following code. Basically it changes on ticket to another.
Replace *YOUR*TICKET*SKU* with the ticket sku that you want to “upgrade” them to
Replace *YOUR*TICKET*ID* with your ticket IDUPDATE events_postmeta
JOIN (
SELECT * FROM events_postmeta
WHERE events_postmeta.meta_key = ‘_sku’
AND events_postmeta.meta_value = ‘*YOUR*TICKET*SKU*’
) AS original
SET events_postmeta.meta_value = original.post_id
WHERE events_postmeta.meta_key = ‘_tribe_wooticket_product’
AND events_postmeta.post_id = ‘*YOUR*TICKET*ID*’;July 18, 2013 at 2:27 pm #55952Barry
MemberThe new status will be reflected. HOWEVER, the total sales and the quantity remaining will not be changed. Meaning that I could have one ticket hanging loose.
That’s correct and that is also expected behaviour, though we can of course understand why not everyone would want that.
It is however part of the design of WooCommerce: for instance, forgetting WooTickets for the moment, if a completed order for 5 x Generic Product is placed, and that order is then cancelled, those 5 items are not restocked.
It’s not really for WooTickets to change the modus operandi of the underlying e-commerce platform, in this case WooCommerce, which is that manual intervention requires manual inventory control (and that is a perfectly sensible approach in many cases) – and so right now our feeling is that this should remain something individual merchants solve with a solution specifically designed to address just that, if indeed they feel it is necessary.
So – don’t get me wrong – we’re genuinely grateful that you’ve taken the time to share your solution, but in general this process is unlikely to be completely incorporated into WooTickets itself.
August 19, 2013 at 8:08 am #61030Barry
MemberClosing this one out since it’s been a while. Thanks again for the tips and snippets, buooy 🙂
July 7, 2015 at 6:27 am #979507Support Droid
KeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘This is the MySQL code to delete tickets’ is closed to new replies.
