Ticket information in the "meta", I want it isolated. [solved]

Home Forums Ticket Products Event Tickets Plus Ticket information in the "meta", I want it isolated. [solved]

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #64218
    frangotier
    Participant

    Hello, I’m trying not to ask something on friday afternoon, so I don’t leave the work forgotten by the time someone answers, sorry about last times.

    I had overriden the single-venue template so I could display minimal information about he venue and the organizer, which is what I want.
    To do so, I echoed tribe_get_meta_group( ‘tribe_event_organizer’ ) and the same with ‘tribe_event_venue’.

    We bought WooTickets yesterday and started working on it. I discover the tickets information could only be displayed as part of the “meta” informations of an event, using: echo tribe_events_single_event_meta()
    Is there a way of displaying the tickets part as a standalone portion on the page?
    (whithout the need for the user to fetch and add the WooCommerce shortcode each time)

    By the way, the event I have affected a ticket to has no cost field anymore. WooTickets fields do take over, I get it. Anyhow, I would still like to display a price for my concerts when they are shown in the sidebar widgets. Is there a way to do it?

    The other stuff I had questions about have been worked around. I now check if I left bugs in what I did to them.

    Still great thanks for being patient with a newbie.

    #64229
    frangotier
    Participant

    Tickets to be placed on top of single event page


    The snippet sort of does the trick, but then I would like to know how to skip the associated events and the Google map in the same way.

    #64336
    Kelly
    Participant

    No problem, frangotier. We’re here to help!

    For forcing the Event Cost field to display with WooCommerce Tickets enabled, please check out this thread: https://theeventscalendar.com/support/forums/topic/event-cost-disabled-with-wootickets-and-i-want-it-back/#post-64070
    That should do the trick for you.

    Would you mind explaining what precisely you mean by “Is there a way of displaying the tickets part as a standalone portion on the page?”? Are you saying you’d like to have the tickets appear in your shop?

    Thanks!

    #64453
    frangotier
    Participant

    Thank you for the advise Kelly.
    First: I found a way for what I called “standalone part”, through the remove/add operation described in my second post. The front-end ticket form is now displayed before the meta as I wanted. It’s now OK as far as the event page is concerned.

    Then…
    I actually saw that thread you link to and tried it. But that’s not what I want… I would like to display, in a public page, the ticket price I attributed via WooTickets. I’m looking for a way to get the price whithout in the whole front-end ticket form.
    My aim is to have it appear next to the event title in the list/month/map view as well as in the sidebar widgets.

    #64467
    Chris
    Participant

    Hi there,
    For a simple product (non variable), any one of these should work:

    echo get_post_meta( get_the_ID(), ‘_regular_price’, true); for the regular price
    echo get_post_meta( get_the_ID(), ‘_sale_price’, true); for hte sale price

    you could also instantiate the product class:
    $product = new WC_Product( get_the_ID() );
    echo $product->price; for plaintext
    or
    echo $product->get_price_html(); for the html version

    or loop in the template:
    woocommerce_get_template( ‘loop/price.php’ );

    -Chris

    #64478
    frangotier
    Participant

    We’re getting somewhere!
    I tried your echos Chris, and the onlyone working is get_price_html();
    It tells me that the concert is free. I understand it goes and fetch the “event” price which is empty. This is normal.
    The price shown in the front-end form to buy a ticket is affected to a custom post which type is “product” and I guess we need to get the ID of that first

    #64479
    Chris
    Participant

    Ah that makes sense, yep. My bad.

    So to grab the id, you’ll need to run a query to get the associated product_id. Something like this should work:
    $id = get_the_ID();
    $woo_product_id = TribeWooTickets::get_instance();
    $query = new WP_Query( array( ‘post_type’ => ‘product’,
    ‘meta_key’ => $wootickets->event_key,
    ‘meta_value’ => $id,
    ‘meta_compare’ => ‘=’,
    ‘posts_per_page’ => – 1,
    ‘fields’ => ‘ids’,
    ‘post_status’ => ‘publish’, ) );

    -Chris

    #64494
    frangotier
    Participant

    Hi Chris. I just tried that, it happens that I had to write
    ‘posts_per_page’ => 1, /* – 1 */
    not to see all the rest of the content disapear.
    Once I had done this i tried each things you advised previously and none worked. I also tried and echo the variables to actually see what they returned and the content was again disapearing.
    I tried sprint_r to see what was grabed, it gives me all of this, the only interresting thingee is the very last one.
    WP_Query Object ( [query] => Array ( [post_type] => product [meta_key] => [meta_value] => 157 [meta_compare] => = [posts_per_page] => 1 [fields] => ids [post_status] => publish ) [query_vars] => Array ( [post_type] => product [meta_key] => [meta_value] => 157 [meta_compare] => = [posts_per_page] => 1 [fields] => ids [post_status] => publish [error] => [m] => 0 [p] => 0 [post_parent] => [subpost] => [subpost_id] => [attachment] => [attachment_id] => 0 [name] => [static] => [pagename] => [page_id] => 0 [second] => [minute] => [hour] => [day] => 0 [monthnum] => 0 [year] => 0 [w] => 0 [category_name] => [tag] => [cat] => [tag_id] => [author_name] => [feed] => [tb] => [paged] => 0 [comments_popup] => [preview] => [s] => [sentence] => [menu_order] => [category__in] => Array ( ) [category__not_in] => Array ( ) [category__and] => Array ( ) [post__in] => Array ( ) [post__not_in] => Array ( ) [tag__in] => Array ( ) [tag__not_in] => Array ( ) [tag__and] => Array ( ) [tag_slug__in] => Array ( ) [tag_slug__and] => Array ( ) [ignore_sticky_posts] => [suppress_filters] => [cache_results] => 1 [update_post_term_cache] => 1 [update_post_meta_cache] => 1 [nopaging] => [comments_per_page] => 50 [no_found_rows] => [order] => DESC ) [tax_query] => WP_Tax_Query Object ( [queries] => Array ( ) [relation] => AND ) [meta_query] => WP_Meta_Query Object ( [queries] => Array ( [0] => Array ( [compare] => = [value] => 157 ) ) [relation] => AND ) [post_count] => 1 [current_post] => -1 [in_the_loop] => [comment_count] => 0 [current_comment] => -1 [found_posts] => 1 [max_num_pages] => 1 [max_num_comment_pages] => 0 [is_single] => [is_preview] => [is_page] => [is_archive] => 1 [is_date] => [is_year] => [is_month] => [is_day] => [is_time] => [is_author] => [is_category] => [is_tag] => [is_tax] => [is_search] => [is_feed] => [is_comment_feed] => [is_trackback] => [is_home] => [is_404] => [is_comments_popup] => [is_paged] => [is_admin] => [is_attachment] => [is_singular] => [is_robots] => [is_posts_page] => [is_post_type_archive] => 1 [query_vars_hash] => 2b1bf46afb5efcb751f46221fff57c87 [query_vars_changed] => [thumbnails_cached] => [tribe_is_past] => [tribe_is_event] => [tribe_is_event_category] => [tribe_is_event_venue] => [tribe_is_event_organizer] => [tribe_is_event_query] => [request] => SELECT SQL_CALC_FOUND_ROWS DISTINCT undergroov_posts.ID FROM undergroov_posts INNER JOIN undergroov_postmeta ON (undergroov_posts.ID = undergroov_postmeta.post_id) WHERE 1=1 AND undergroov_posts.post_type = ‘product’ AND (undergroov_posts.post_status = ‘publish’) AND ( (CAST(undergroov_postmeta.meta_value AS CHAR) = ‘157’) ) GROUP BY undergroov_posts.ID ORDER BY undergroov_posts.post_date DESC LIMIT 0, 1 [posts] => Array ( [0] => 217 ) )

    Pretty messy! But that 217 is the ID of my ticket, whereas 157 is the ID of my event, so it’s grabing something interresting though.

    #64743
    Chris
    Participant

    Hi there,
    That – 1 was actually supposed to be -1
    The ID of the ticket is the same as the id of the product in WooCommerce.

    So if you put that ID (using the variable) where get_the_ID() was, you should be good to go.

    #64861
    frangotier
    Participant

    -1 
    I should have tried that first!
    I won’t look into that deeply enough before next week now, but i let you know how it goes.

    Just for not closing the topic yet…

    #64865
    Chris
    Participant

    Not a problem, though now that I think of it, plain 1 might be better. -1 will return all product ID’s attached to an event, which will return an array of numbers if you have more than 1 product attached to an event. 1 will return the first product attached, so you know it will just be an integer (though WordPress will put it in an array anyways).

    Depends really on how you want to handle something like that

    #65278
    frangotier
    Participant

    All right, 1 will fit if I have only one ticket per concert, -1 will do if I have several.
    That’s very kind of you to bend over our problem.

    Right now I would like to isolated that [posts] => Array ( [0] => 217 ) in the very end. From that on I feel I could at last display something concerning my ticket.
    What would you type after the new WP_Query to display the “_regular_price” or at least the “217” to work with?

    I asked my collegue how he would do with plain PHP. We tried this:
    /* I assume i’ve got $wpbd to gather the conection information*/
    $toto = get_the_ID();
    $prix = $wpbd -> get_results(“SELECT * FROM undergroov_postmeta WHERE meta_key=’_regular_price’ AND post_id='”.$toto.”‘”);
    WHILE ($voir_prix = $prix -> fetch() ){
    $prix_concert = $voir_prix[‘meta_value’];
    echo $prix_concert ;
    }
    /**/
    But all it does is to prevent the botom of the page to dsisplay…

    #65283
    Chris
    Participant

    So the query above gets saved to the variable. So now we just call woo’s pricing with it:

    $id = get_the_ID();
    $wootickets = TribeWooTickets::get_instance();
    $query = new WP_Query( array( ‘post_type’ => ‘product’,
    ‘meta_key’ => $wootickets->event_key,
    ‘meta_value’ => $id,
    ‘meta_compare’ => ‘=’,
    ‘posts_per_page’ => 1,
    ‘fields’ => ‘ids’,
    ‘post_status’ => ‘publish’, ) );
    echo get_post_meta( $query, ‘_regular_price’, true);

    should do it

    #65293
    frangotier
    Participant

    It doesn’t work either. But at least the rest of the page is OK

    #65430
    frangotier
    Participant

    I went and look in the database tables:
    The ticket (ID:217) has a key named ‘_tribe_wooticket_for_event’ which is set to ‘157’.
    The event (ID:157) has no such key to indicate an associate ticket.
    I could display my price via:

    $meta_truc = get_post_meta( get_the_ID(), ‘_EventCurrencySymbol’, true );
    $meta_bidule = get_post_meta( 217, ‘_regular_price’, true );
    echo $meta_bidule . ‘ ‘.$meta_truc ;

    But I still need to know that 217 to do it
    All I need now is to write something saying to the server “please show me a post which key ‘_tribe_wooticket_for_event’ is equal to the value of [get_the_id()] of the current post”

Viewing 15 posts - 1 through 15 (of 19 total)
  • The topic ‘Ticket information in the "meta", I want it isolated. [solved]’ is closed to new replies.