Generate a custom notice when a Wooticket ticket product is purchasable

Home Forums Ticket Products Event Tickets Plus Generate a custom notice when a Wooticket ticket product is purchasable

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1004799
    bottegadelpossibile
    Participant

    I need to generate a custom notice only when a Wooticket ticket product is purchasable, both in the list that in single events.

    I have tried to show my notice using: if (tribe_get_cost()) and when a ticket exists, my custom notice is working. However when the ticket is no longer purchasable the notice continues to be displayed.

    There is a function or a way suitable to the purpose?

    Thanks

    #1005050
    George
    Participant

    Hey @bottegadelpossibile,

    We unfortunately don’t offer support for customizations here, so you’ll mostly have to take the reins here on your own, but with that being said, I’m happy to at least try and offer some insight here to help you on your way.

    It sounds like the displaying of your notice should depend on the date of your event correct? I.e. that by “not purchasable” you mean that the event for the ticket has passed, is that right?

    If not, let me know what exactly makes a ticket “purchasable” or “not purchasable” on your site – I can help from there and hopefully share a way for you to detect this status on a given ticket, so you can display the message or not πŸ™‚

    Cheers,
    George

    #1005607
    bottegadelpossibile
    Participant

    To generate the notification would be a good solution also depend on the date of the event. (If you can tell me how πŸ˜‰ )

    However I’ll explain what I mean when I say that the ticket is no longer purchasable:

    In wooticket section of event post there are 2 field, start and end date of sell (yellow in screenshot):

    https://www.dropbox.com/s/ioa6mykoi7i714l/wooticket%20section%20yellow.PNG?dl=0

    In this section I can choose the period during which the ticket is sold. During this time I consider it “purchasable” and before and after this time “not purchasable” πŸ˜€


    @George
    Thank you very much

    #1005772
    George
    Participant

    Hey @bottegadelpossibile,

    Thanks for the update! This is unfortunately a bit more complicated to reliably pull off than it seems, but the good news is that there is a good amount of existing code that you should be able to read through and take code from: head to /src/views/wootickets/tickets.php in your WooCommerce Tickets plugin files, and look for the variable called $is_there_any_product_to_sell

    Now, if you steal the logic used to make this variable “true” or “false”, you could then use that anywhere on your site that you desire – and if true, i.e. there is a “Purchasable” ticket, then you can display one notice; if false, i.e. there is not a “purchasable” ticket, then you can display another notice…

    I hope you find this code useful and are able to make the customization you seek to make on your site!

    Best of luck with your customizations,
    George

    #1006834
    bottegadelpossibile
    Participant

    I analyzed the logic to get the variable $is_there_any_product_to_sell true. However, by using it, for example, in single- event.php, the date that is used is always the one of the event itself.

    Some advice for more? πŸ™‚

    Thank you

    #1007153
    George
    Participant

    Hey @bottegadelpossibile,

    I’m glad that you were able to get started on your customization here – if you’re stuck getting data from the event itself and not the tickets, then it sounds like you may not have constructed your $tickets loop correctly.

    What this means is that, for example, in parts of the code already you’ll see this is_there_any_product_to_sell variable only existing inside a loop like foreach ( $tickets as $ticket ) – you should use a foreach loop like this yourself to loop through existing tickets, and then inside the loop you can use data directly from the ticket by pointing to $ticket->ID.

    I’ll unfortunately have to close up this thread for now, since we do not offer help with customizations, but I hope the information I’ve shared here helps! πŸ™‚

    Best of luck with your project,
    George

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Generate a custom notice when a Wooticket ticket product is purchasable’ is closed to new replies.