[Plugin: Events Manager] Problem booking someone programmaticly.
-
I now get a ticketing error. (missing field ticket_booking_spaces) I had to change the validate routine to use the real field name and not the “true” field name (see code below. I’m not sure what that is. Should I be setting ticket_booking_spaces or spaces?
I’m also getting a RSVP error “You cannot manage this Booking”. I’m looking into that now.
Here is how I’ll reserving a spot for someone”
$rsvp->booking_status = $rsvp_status;
$rsvp->booking_spaces = $_POST[‘guests’]+1;
$rsvp->booking_comment = htmlentities($_POST[‘rsvp_comment’]);
$rsvp->event_id = $event->id();
$rsvp->person_id = $hap_user->id();
$tickets = $rsvp->get_tickets();$tb = new EM_Ticket_Booking();
$tb->booking_id = $rsvp->booking_id;
$tb->ticket_id = $tickets->tickets[0]->ticket_id;
$tb->ticket_booking_price = $tickets->tickets[0]->ticket_price;
$tb->ticket_booking_spaces = strval($_POST[‘guests’]+1);
$tb->save();$rsvp->save();
——————————————————————–
class EM_Ticket_Booking
Original
function validate(){
$missing_fields = Array ();
foreach ( $this->required_fields as $field ) {
$true_field = $this->fields[$field][‘name’];
if ( $this->$true_field == “”) {
$missing_fields[] = $field;
}
}
if ( count($missing_fields) > 0){
// TODO Create friendly equivelant names for missing fields notice in validation
$this->errors[] = __ ( ‘Missing fields: ‘ ) . implode ( “, “, $missing_fields ) . “. “;
}
return apply_filters(’em_event_validate’, count($this->errors) == 0, $this );
}modified
function validate(){
$missing_fields = Array ();
foreach ( $this->required_fields as $field ) {
$true_field = $this->fields[$field][‘name’];
if ( $this->$field == “”) {
$missing_fields[] = $field;
}
}
if ( count($missing_fields) > 0){
// TODO Create friendly equivelant names for missing fields notice in validation
$this->errors[] = __ ( ‘Missing fields: ‘ ) . implode ( “, “, $missing_fields ) . “. “;
}
return apply_filters(’em_event_validate’, count($this->errors) == 0, $this );
}
- The topic ‘[Plugin: Events Manager] Problem booking someone programmaticly.’ is closed to new replies.