Add to Cart button inside of month template view

Home Forums Ticket Products Event Tickets Plus Add to Cart button inside of month template view

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1012542
    Justin
    Participant

    I can see on individual event pages the add to cart gets pulled in via the tickets.php template to create add to cart ability, I’d like to make that template available inside of the month/single-event.php template.

    Is this possible? How might I go about this?

    Thanks,

    Justin

    #1012709
    Brian
    Keymaster

    Hi,

    Thanks for using our plugins I can try to help out here.

    We do not have a feature to do this so I am limited in supporting it.

    However, you could try using a WooCommerce Shortcode to add the ticket in month view:

    <?php echo do_shortcode( '[add_to_cart id="309"]'); ?>

    I tested it out and was able to add a ticket to the cart.

    It would need some coding to detect the ticket product id and add it to the shortcode or else the same ticket would be in all events.

    Or you could create a custom field using ACF and add the shortcode there and then only run it if there is content in the custom field for that event.

    I can try to help out and answer some more questions to get you started, but I am limited in support a customization much beyond this.

    Thanks

    #1013300
    Justin
    Participant

    Thanks Brian,

    So I have a solution using ACF that works though isn’t as streamlined as I would like.

    <a href="/?add-to-cart=<?php the_field('woo_post_id');?>">

    It’s nothing ground breaking but requires the user to enter the WooCommerece product ID into a field on the edit events page and then we have a click to add product to cart button in the menu.

    In an effort to make this more dynamic & streamlined, is there any way to access the Woo product ID from within the events loop?

    #1013603
    Brian
    Keymaster

    Hi,

    What about using this method outlined here:

    $woo_tickets = Tribe__Events__Tickets__Woo__Main::get_instance();
    $ticket_ids = $woo_tickets->get_tickets_ids( get_the_id() );

    foreach ( $ticket_ids as $ticket_id ) {
    printf( '<h3>%s</h3>', get_the_title( $ticket_id ) );
    }

    I am not sure if get_the_id() works there, but that is just the event id you might be able to directly add it there from a variable.

    Anyway this returns all the ticket ids for an event.

    If it finds an id you could then display the add to cart button by replacing the printf() function.

    Do you think that will work?

    #1014241
    Justin
    Participant

    Brian –
    That seems to be returning the event ID and not the WooCommerce product ID.

    TBH, I’m going to tell the client this is out of their development scope before I start going over budget.

    Thanks for all your help!

    -Justin

    #1014316
    Brian
    Keymaster

    Ok Sounds good, I did not test in the Month View so maybe there is needs to be modified.

    Since this is marked resolved 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

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Add to Cart button inside of month template view’ is closed to new replies.