Home › Forums › Ticket Products › Event Tickets Plus › Set default SKU of all tickets
- This topic has 10 replies, 3 voices, and was last updated 9 years, 7 months ago by
Frank.
-
AuthorPosts
-
August 25, 2016 at 8:08 am #1155806
Frank
ParticipantHi,
I have 260 tickets for all events (5 tickets per events).
I would like to update SKU (UGS) of every ticket and name it like TITLE_OF_EVENT-START_DATE-START_TIME-TICKET_NAME
Is anyone have a PHP or SQL snippet to do it? It would save me a LOT of time 😉
Thanks,
FrankAugust 25, 2016 at 4:17 pm #1156102Andras
KeymasterSalut Frank,
Thanks for reaching out! Let me try to help you with your question.
What you want to achieve can be done with customization, however we are quite limited in providing support for that, but I can point you in the right direction.
Please check this thread and the snippet provided at the end.
What this does is, it copies the category of the event to the WooCommerce ticket, if one is created.
You could adjust this code to your needs to create the ticket SKUs.
I think you will need these functions as well:
https://theeventscalendar.com/function/tribe_get_events_title/
https://theeventscalendar.com/function/tribe_get_start_date/
https://theeventscalendar.com/function/tribe_get_start_time/You can also check WooCommerce documentation how to handle SKU names and where / how they are saved.
Let me know if this helps or if you have any more questions.
Cheers,
AndrasAugust 26, 2016 at 12:26 am #1156225Frank
ParticipantHey Andras,
Thanks for your message. The snippet you posted could do the trick, but I should review each ticket one by one to update the SKU. As there are 260 tickets, it will be a bit time consuming to me 😉
Would you have any other functions (PHP or SQL) to update all SKU tickets in one shot?
Thanks,
FrankAugust 26, 2016 at 5:42 am #1156285Andras
KeymasterHi Frank,
Unfortunately I don’t have a handy function like that on hand, sorry. The 260 tickets can indeed be time consuming, however, you just need to re-save the tickets in the event, you don’t need to resave the event (unless you change something there as well).
I will ask around in the team if someone has a script for that, but that will take a bit of time.
Cheers,
Andras
August 26, 2016 at 6:11 am #1156294Frank
ParticipantHey Andras,
I wrote a PHP script which update the sku of all tickets. Use on a WordPress install with only Event Tickets Plus products, otherwise it could throw errors or break database.
The script is a bit messy (while in while in while) but I don’t have time enough to make it cleaner. I could write a plugin to select which fields to generate the SKU if I would have time.
https://gist.github.com/frankbergere/fc43602156f9065e895b2064700cfa1f
Thanks again for your messages, it gave me ideas to release it 🙂
Have a great day!
FrankAugust 26, 2016 at 8:16 am #1156335Andras
KeymasterI keep my fingers crossed for you, Frank!
Please let me know how it works out and would be great if you could share the code here. Might help some others with a similar problem.
I will leave this ticket open so you can do that if you want to share.
Have a great weekend!
Cheers,
AndrasAugust 26, 2016 at 8:32 am #1156346Frank
ParticipantHey Andras,
The script works. Just put the file on your wp install root folder (same level than wp-config), customize the database parameters et change db_prefix_ by your own prefix and run the script via your browser http://yourdomain.com/event_tickets_plus_update_sku.php
Have a nice week-end too!
Frank-
This reply was modified 9 years, 8 months ago by
Frank.
August 29, 2016 at 2:41 pm #1157279Andras
KeymasterHello Frank,
Thanks a lot or posting this! I think when you changed the domain to yourdomain.com it also broke the link. Could you post the code in GitHub or BitBucket or something similar?
Thanks,
AndrasAugust 30, 2016 at 12:37 am #1157448Frank
ParticipantHey Andras,
The script is already on GitHub : https://theeventscalendar.com/support/forums/topic/set-default-sku-of-all-tickets/#post-1156294
Here’s the link of the raw format : “https://gist.github.com/frankbergere/fc43602156f9065e895b2064700cfa1f/raw/36dfb28d569e215d22c4ec50465639519eb0678e/event_tickets_plus_update_sku.php”
Cheers,
Frank-
This reply was modified 9 years, 7 months ago by
Frank.
August 30, 2016 at 12:54 pm #1157790Andras
KeymasterThat’s awesome Frank, thanks a bunch!
I am going to close this ticket, but if you need anything else related to this topic or another please post a new topic on the forum and we can help you out.
Thanks and cheers,
Andras -
This reply was modified 9 years, 8 months ago by
-
AuthorPosts
- The topic ‘Set default SKU of all tickets’ is closed to new replies.
