Forum Replies Created
-
AuthorPosts
-
John OsmondParticipant
Hi Victor. I appreciate the suggestions. In this case, I finally
convinced the customer to just install those two plugins. Thanks. — JOJohn OsmondParticipantHi BJ. I was having a problem with the APM filters and confirmed that there is definitely a conflict with Yoast SEO. But I discovered that if you turn of the Yoast feature called the “Text Link Counter” then the filters will work again.
Hope that helps.
John OsmondParticipantI think I’ve figured this out. It’s a specific feature in Yoast – the “Text Link Counter”. When I turn off this feature I get my APM filters back. So for me, this is resolved because I don’t even know what that feature is for.
But for others who want to use that feature and the APM filters, there does seem to be a conflict.
John OsmondParticipant^ Ok, those screen shots went in the opposite order. The first one is my filter list AFTER I activate Yoast. The second one is with Yoast not active.
John OsmondParticipantThank you for you reply. This is still an issue for me. Following the thread I have done this:
1) changed my theme to twentyseventeen
2) deactivated all plugins except: a) Advanced Post Manager; b) Event Tickets; c) Event Tickets Plus; d) The Events Calendar; e) The Events Calendar Pro.
3) In this state APM filters work properly (I’ll attach a screen shot).
4) If I activate SEO by Yoast then APM filters stop working (second screen shot)Oddly, the list will say “2 items”, but will list 20 events, none of which are the 2 I was expecting. It seems they are being crowded out by some Recurring Events that go to November or December.
October 21, 2016 at 11:20 am in reply to: Fatal error brought down entire site after updating EC PRO to 4.3.1 #1180813John OsmondParticipantLooks they got a fix on this already. Good job tri.be. Get version 3.4.1.1 and it is resolved.
October 21, 2016 at 10:37 am in reply to: Fatal error brought down entire site after updating EC PRO to 4.3.1 #1180788John OsmondParticipantUPDATE: I said something incorrect in my original post. If you have a file editor, you can change line 97 to read: “return false;” (and delete or comment out everything else on that line) then the plugin works.
It breaks that one function, but it’s sort of an obscure function anyway. They should fix this, but I can live without “tribe_venue_has_next_events” functionality for now.
October 21, 2016 at 10:32 am in reply to: Fatal error brought down entire site after updating EC PRO to 4.3.1 #1180782John OsmondParticipantIf you have access to your files (thru ftp, or cpanel?) then just find the folder called “events-calendar-pro” in the “plugins” folder. Rename it to something like “events-calendar-pro_old”.
Then your site should work again, but the EC Pro will be deactivated.
John OsmondParticipantOk, thanks for pointing me in the direction of the get_event_tickets function. It was exactly what I needed. Here are two functions that you might share with other users.
function event_has_ticket_type_rsvp($event_id) { $breturn = FALSE; //init if ( class_exists( 'Tribe__Tickets__Tickets' ) ) { $tickets = Tribe__Tickets__Tickets::get_event_tickets($event_id); foreach( $tickets as $ticket ) { if( strpos(strtolower($ticket->provider_class), 'rsvp') !== FALSE ) $breturn = TRUE; } } return $breturn; }
function jt10_event_has_ticket_type_woocommerce($event_id) { $breturn = FALSE; //init if ( class_exists( 'Tribe__Tickets__Tickets' ) ) { $tickets = Tribe__Tickets__Tickets::get_event_tickets($event_id); foreach( $tickets as $ticket ) { if( strpos(strtolower($ticket->provider_class), 'woocommerce') !== FALSE ) $breturn = TRUE; } } return $breturn; }
Thanks for the help!
John OsmondParticipantHi Cliff. Sorry about the inconsistency. I had to remove the rsvp tickets from the first responders night because this is a live site and it was confusing people.
However, if I may boil my question down: Is there a php function I can call (passing in the $event_id) to determine whether or not an event has any tickets of the ‘RSVP’ type?
Thanks
John OsmondParticipantI realize now that since it is possible for an event to have a mixed set of ticket types, my requested function would not make sense. It would be nice to test if an event “has” one type or another.
So my code might look like:
<?php if( tribe_events_event_has_ticket_type_rsvp($event_id) ): ?> <p><a href="#rsvp_tickets">Make your reservation now.</a></p> <?php endif; ?> <?php if( tribe_events_event_has_ticket_type_woocommerce($event_id) ): ?> <p><a href="#purchase_tickets">Purchase tickets here.</a></p> <?php endif; ?>
John OsmondParticipantSure Cliff, and thanks for the reply. I run a comedy club and sometimes we do fundraiser events. Some of those are for pay and some are free. When they are for pay I add a ticket and select the ‘WooCommerce’ radio button. When they are free I add a ticket using ‘RSVP’.
In the event template file (a php file, which I have located in my own theme and in the proper place) I echo out a link at the top that says ‘Purchase Tickets’. The link points to the bottom of the page where the ticket order form is.
Here is one such event: https://snappersgrill.com/event/hard2guard/
It would be nice if I could detect the type of event and if ‘RSVP’ then echo out a more appropriate link, maybe ‘Make your reservations now’, instead of ‘Purchase tickets’.
Here is an event like that: https://snappersgrill.com/event/first-responders-night/
The code I’m using now:
<?php if( tribe_events_has_tickets($event_id) ): ?> <p><a href="#purchase_tickets">Purchase Tickets</a></p> <?php endif; ?>
I would like something like (and I’m making this function name up myself):
<?php if( tribe_events_has_tickets($event_id) ): ?> <?php if( tribe_events_ticket_type == 'rsvp' ): ?> <p><a href="#purchase_tickets">Make your reservation now.</a></p> <?php else: ?> <p><a href="#purchase_tickets">Purchase Tickets</a></p> <?php endif; ?> <?php endif; ?>
John OsmondParticipantI think I got it figured out. This seems to be working:
class myclass {
public function create_tickets( $event_id ) {
// this function will create a set of tickets for any given event
// it looks to the acf options page for default tickets$sku = tribe_get_start_date($event_id, true, ‘YmdHi’); //sku base on date/time
$start_date_time = tribe_get_start_date($event_id, true, ‘m/d @ g:i’); //becomes part of the titleif( have_rows(‘show_default_ticket_packages’, ‘option’) ) {
while( have_rows(‘show_default_ticket_packages’, ‘option’ ) ) {
the_row();
$ticket_title = get_sub_field(‘default_ticket_pkg_title’, ‘option’);
$ticket_desc = get_sub_field(‘default_ticket_pkg_desc’, ‘option’);
$ticket_desc = strip_tags($ticket_desc); // gotta strip tags
$ticket_price = get_sub_field(‘default_ticket_pkg_price’, ‘option’);$ticket = new TribeEventsTicketObject();
$ticket->description = $ticket_desc;
$ticket->name = “$ticket_title $start_date_time”;
$ticket->price = $ticket_price;$raw_data = array();
$raw_data[‘ticket_woo_stock’] = 80; // TODO: parse out to new options field
$raw_data[‘ticket_woo_sku’] = $sku;$this->save_ticket( $event_id, $ticket, $raw_data );
}
}
}// this part I got from you guys
/**
* Saves a given ticket (WooCommerce product)
*
* @param int $event_id
* @param TribeEventsTicketObject $ticket
* @param array $raw_data
*
* @return bool
*/
private function save_ticket( $event_id, $ticket, $raw_data = array() ) {
if ( empty( $ticket->ID ) ) {
/* Create main product post */
$args = array( ‘post_status’ => ‘publish’,
‘post_type’ => ‘product’,
‘post_author’ => get_current_user_id(),
‘post_excerpt’ => $ticket->description,
‘post_title’ => $ticket->name );$ticket->ID = wp_insert_post( $args );
update_post_meta( $ticket->ID, ‘_visibility’, ‘hidden’ );
update_post_meta( $ticket->ID, ‘_tax_status’, ‘taxable’ );
update_post_meta( $ticket->ID, ‘_tax_class’, ” );
update_post_meta( $ticket->ID, ‘_purchase_note’, ” );
update_post_meta( $ticket->ID, ‘_weight’, ” );
update_post_meta( $ticket->ID, ‘_length’, ” );
update_post_meta( $ticket->ID, ‘_width’, ” );
update_post_meta( $ticket->ID, ‘_height’, ” );
update_post_meta( $ticket->ID, ‘_downloadable’, ‘no’ );
update_post_meta( $ticket->ID, ‘_virtual’, ‘yes’ );
update_post_meta( $ticket->ID, ‘_sale_price_dates_from’, ” );
update_post_meta( $ticket->ID, ‘_sale_price_dates_to’, ” );
update_post_meta( $ticket->ID, ‘_product_attributes’, array() );
update_post_meta( $ticket->ID, ‘_sale_price’, ” );
update_post_meta( $ticket->ID, ‘total_sales’, 0 );// Relate event <—> ticket
$event_key = ‘_tribe_wooticket_for_event’;add_post_meta( $ticket->ID, $event_key, $event_id );
} else {
$args = array( ‘ID’ => $ticket->ID,
‘post_excerpt’ => $ticket->description,
‘post_title’ => $ticket->name );$ticket->ID = wp_update_post( $args );
}if ( ! $ticket->ID )
return false;update_post_meta( $ticket->ID, ‘_regular_price’, $ticket->price );
update_post_meta( $ticket->ID, ‘_price’, $ticket->price );if ( trim( $raw_data[‘ticket_woo_stock’] ) !== ” ) {
$stock = (int) $raw_data[‘ticket_woo_stock’];
$status = ( 0 < $stock ) ? ‘instock’ : ‘outofstock’;update_post_meta( $ticket->ID, ‘_stock’, $stock );
update_post_meta( $ticket->ID, ‘_stock_status’, $status );
update_post_meta( $ticket->ID, ‘_backorders’, ‘no’ );
update_post_meta( $ticket->ID, ‘_manage_stock’, ‘yes’ );
delete_transient( ‘wc_product_total_stock_’ . $ticket->ID );
} else {
update_post_meta( $ticket->ID, ‘_manage_stock’, ‘no’ );
}if ( isset( $raw_data[‘ticket_woo_sku’] ) )
update_post_meta( $ticket->ID, ‘_sku’, $raw_data[‘ticket_woo_sku’] );if ( isset( $ticket->start_date ) ) {
update_post_meta( $ticket->ID, ‘_ticket_start_date’, $ticket->start_date );
} else {
delete_post_meta( $ticket->ID, ‘_ticket_start_date’ );
}if ( isset( $ticket->end_date ) ) {
update_post_meta( $ticket->ID, ‘_ticket_end_date’, $ticket->end_date );
} else {
delete_post_meta( $ticket->ID, ‘_ticket_end_date’ );
}wp_set_object_terms( $ticket->ID, ‘Ticket’, ‘product_cat’, true );
return true;
}
}// /myclassJohn OsmondParticipantSo that’s it? Can you give me some ideas where to look.
Clearly the WooTickets form does it thru an ajax call. Isn’t there some php functions that I can pass the event_id to along with a data array and create a ticket?
-
AuthorPosts