Fixed bug where checkout questions with multiple selections were not being saved + small checkout bug fixes

This commit is contained in:
Dave Earley 2016-05-06 00:18:52 +01:00
parent 49b0fac0f5
commit e4f6e8cb26
5 changed files with 23 additions and 9 deletions

View File

@ -250,6 +250,20 @@ class EventCheckoutController extends Controller
*/
public function postCreateOrder(Request $request, $event_id)
{
/*
* If there's no session kill the request and redirect back to the event homepage.
*/
if( ! session()->get('ticket_order_' . $event_id)) {
return response()->json([
'status' => 'error',
'message' => 'Your session has expired.',
'redirectUrl' => route('showEventPage', [
'event_id' => $event_id,
])
]);
}
$mirror_buyer_info = ($request->get('mirror_buyer_info') == 'on');
$event = Event::findOrFail($event_id);
$order = new Order;
@ -536,7 +550,12 @@ class EventCheckoutController extends Controller
*/
foreach ($attendee_details['ticket']->questions as $question) {
/*
* If there are multiple answers to a question then joing them with a comma
* and treat them as a single answer.
*/
$ticket_answer = $ticket_questions[$attendee_details['ticket']->id][$i][$question->id];
$ticket_answer = is_array($ticket_answer) ? implode(', ', $ticket_answer) : $ticket_answer;
if(!empty($ticket_answer)) {
QuestionAnswer::create([

View File

@ -36,7 +36,7 @@ $(function() {
if(data.redirectData) {
$.redirectPost(data.redirectUrl, data.redirectData);
} else {
window.location = data.redirectUrl;
document.location.href = data.redirectUrl;
}
}

View File

@ -13567,7 +13567,7 @@ function log() {
if(data.redirectData) {
$.redirectPost(data.redirectUrl, data.redirectData);
} else {
window.location = data.redirectUrl;
document.location.href = data.redirectUrl;
}
}

View File

@ -46,11 +46,6 @@
<fieldset id="question-options" {!! empty($question->has_options) ? ' class="hide"' : '' !!}>
<h4>Question Options</h4>
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th colspan="2">Option name</th>
</tr>
</thead>
<tbody>
<tr>
<td><input class="form-control" name="option[]" type="text" value=""></td>

View File

@ -10,12 +10,12 @@
@elseif($question->question_type_id == config('attendize.question_dropdown_single'))
{!! Form::select("ticket_holder_questions[{$ticket->id}][{$i}][$question->id]", $question->options->lists('name', 'name'), null, ['required' => $question->is_required ? 'required' : '', 'class' => "ticket_holder_questions.{$ticket->id}.{$i}.{$question->id} form-control"]) !!}
@elseif($question->question_type_id == config('attendize.question_dropdown_multi'))
{!! Form::select("ticket_holder_questions[{$ticket->id}][{$i}][$question->id]",$question->options->lists('name', 'name'), null, ['required' => $question->is_required ? 'required' : '', 'multiple' => 'multiple','class' => "ticket_holder_questions.{$ticket->id}.{$i}.{$question->id} form-control"]) !!}
{!! Form::select("ticket_holder_questions[{$ticket->id}][{$i}][$question->id][]",$question->options->lists('name', 'name'), null, ['required' => $question->is_required ? 'required' : '', 'multiple' => 'multiple','class' => "ticket_holder_questions.{$ticket->id}.{$i}.{$question->id} form-control"]) !!}
@elseif($question->question_type_id == config('attendize.question_checkbox_multi'))
<br>
@foreach($question->options as $option)
{{$option->name}}
{!! Form::checkbox("ticket_holder_questions[{$ticket->id}][{$i}][$question->id]",$option->name, false,['class' => "ticket_holder_questions.{$ticket->id}.{$i}.{$question->id} form-control"]) !!}<br>
{!! Form::checkbox("ticket_holder_questions[{$ticket->id}][{$i}][$question->id][]",$option->name, false,['class' => "ticket_holder_questions.{$ticket->id}.{$i}.{$question->id} form-control"]) !!}<br>
@endforeach
@elseif($question->question_type_id == config('attendize.question_radio_single'))
<br>