'Book' button on event list page AND on Event Description

Home Forums Ticket Products Event Tickets Plus 'Book' button on event list page AND on Event Description

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #48098
    1vertica
    Participant

    We want the ability to output a ‘Book’ button on the event listings page that has the woocommerce add to cart URL behind it so that customers can book tickets straight from the events list page.

    We are also wanting the exact same button on the event description page.

    There is something similar in the showcase page https://theeventscalendar.com/showcase-item/victoria-symphony/

    Woocommerce, when it creates a product also creates a unique add to cart url for that product and it is that we want to look up and add to the page template.

    Wootickets currently does this using a form but we no longer even have that – this is after Barry kindly fixed another problem for us so we don’t want to make any changes to his changes without some guidance.

    Any suggestions?

    #48114
    Barry
    Member

    Hi 1vertica,

    With the same changes I suggested you make on your test site I don’t experience the same lack of a WooTickets form. We can definitely look into why that isn’t working for you (if you want to use the WooTickets default form that is).

    In terms of adding an add to cart link, you could add these functions to your theme’s functions.php file. At the relevant point in your template you could then add:

    <?php add_to_cart_wooticket_btns() ?>

    Points to note: you need to do this in the context of an event, for instance next to the_content() or the_excerpt(), otherwise it will not know for which event you wish to obtain add-to-cart links.

    Another point is that it adds items to the cart but does not take them to the actual cart page (it simply behaves as per the [add_to_cart_url] shortcode provided by WooCommerce).

    Hope that gives you a starting point to work from 🙂

    #48130
    Mike
    Participant

    How would one alter this code to also take them to the checkout page?

    #48133
    Barry
    Member

    If you inspect the URL you can see there is a query appended like so:

    ?add-to-cart=x

    Where x is the product ID. The WooCommerce [add_to_cart_url] shortcode seems to append this to the current page URL by default – but it also functions if you use it with the cart URL, something like:

    example.com/cart/?add-to-cart=x

    WooCommerce may offer a hook to simply change the behaviour of the shortcode, or you could even create your own function to build this.

    #49018
    Barry
    Member

    I’ll go ahead and close this – as usual feel free to create new threads if you need further help on this end.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘'Book' button on event list page AND on Event Description’ is closed to new replies.