From e4f6e8cb26bab583a38277f6c4f91c3acefa90f4 Mon Sep 17 00:00:00 2001 From: Dave Earley Date: Fri, 6 May 2016 00:18:52 +0100 Subject: [PATCH] Fixed bug where checkout questions with multiple selections were not being saved + small checkout bug fixes --- .../Controllers/EventCheckoutController.php | 19 +++++++++++++++++++ public/assets/javascript/app-public.js | 2 +- public/assets/javascript/frontend.js | 2 +- .../Modals/CreateQuestion.blade.php | 5 ----- .../Partials/AttendeeQuestions.blade.php | 4 ++-- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/EventCheckoutController.php b/app/Http/Controllers/EventCheckoutController.php index 43790e9d..f6b0a327 100644 --- a/app/Http/Controllers/EventCheckoutController.php +++ b/app/Http/Controllers/EventCheckoutController.php @@ -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([ diff --git a/public/assets/javascript/app-public.js b/public/assets/javascript/app-public.js index 7402b46f..4e84a41e 100644 --- a/public/assets/javascript/app-public.js +++ b/public/assets/javascript/app-public.js @@ -36,7 +36,7 @@ $(function() { if(data.redirectData) { $.redirectPost(data.redirectUrl, data.redirectData); } else { - window.location = data.redirectUrl; + document.location.href = data.redirectUrl; } } diff --git a/public/assets/javascript/frontend.js b/public/assets/javascript/frontend.js index a1c80910..57189673 100644 --- a/public/assets/javascript/frontend.js +++ b/public/assets/javascript/frontend.js @@ -13567,7 +13567,7 @@ function log() { if(data.redirectData) { $.redirectPost(data.redirectUrl, data.redirectData); } else { - window.location = data.redirectUrl; + document.location.href = data.redirectUrl; } } diff --git a/resources/views/ManageEvent/Modals/CreateQuestion.blade.php b/resources/views/ManageEvent/Modals/CreateQuestion.blade.php index 4b1ef7a0..0c08c632 100644 --- a/resources/views/ManageEvent/Modals/CreateQuestion.blade.php +++ b/resources/views/ManageEvent/Modals/CreateQuestion.blade.php @@ -46,11 +46,6 @@
has_options) ? ' class="hide"' : '' !!}>

Question Options

- - - - - diff --git a/resources/views/Public/ViewEvent/Partials/AttendeeQuestions.blade.php b/resources/views/Public/ViewEvent/Partials/AttendeeQuestions.blade.php index fb85914b..69852da9 100644 --- a/resources/views/Public/ViewEvent/Partials/AttendeeQuestions.blade.php +++ b/resources/views/Public/ViewEvent/Partials/AttendeeQuestions.blade.php @@ -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'))
@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"]) !!}
+ {!! Form::checkbox("ticket_holder_questions[{$ticket->id}][{$i}][$question->id][]",$option->name, false,['class' => "ticket_holder_questions.{$ticket->id}.{$i}.{$question->id} form-control"]) !!}
@endforeach @elseif($question->question_type_id == config('attendize.question_radio_single'))
Option name