Ticket QTY Picker Disappears
WordPress Event Management, Calendars & Registration › Forums › Report A Bug › Ticket QTY Picker Disappears
This topic contains 13 replies, has 2 voices, and was last updated by Paul Oaten 7 years, 6 months ago.
-
AuthorPosts
-
March 1, 2017 at 7:33 pm #26334
Hi Stephen,
I have a weird issue which has just been discovered on the event booking form.
Basically, the QTY picker appears and then immediately disappears once the page has loaded. Example here: https://www.panary.co.uk/craft-baking-courses/1-day-basic/
I have checked all settings but they really haven’t changed for ages. The problem only seems to occur if I’m logged out. When logged-in, I see the qty picker ok but only if I go into the event editor and re-save the event.
Versions installed:
Event Organiser: 3.1.7
Event Organiser Pro: 1.11.9I’ve done a bit more checking in the Chrome Dev Tools and the console shows the following error:
Uncaught TypeError: Cannot read property ‘tickets’ of undefined
at occurrence-picker.min.js?ver=1.11.9:2
at Function.m.each.m.forEach (underscore.min.js?ver=1.8.3:5)
at n.each (backbone.min.js?ver=1.2.3:1)
at n.set_ticket_event_availability (occurrence-picker.min.js?ver=1.11.9:2)
at n.initialize (occurrence-picker.min.js?ver=1.11.9:2)
at n.e.Model (backbone.min.js?ver=1.2.3:1)
at new n (backbone.min.js?ver=1.2.3:1)
at occurrence-picker.min.js?ver=1.11.9:2Does that help?
Grateful for any assistance
Paul OatenMarch 1, 2017 at 7:43 pm #26335Hi Paul,
Could you enable
SCRIPT_DEBUG
in yourwp-config.php
. That will use the non-minifed version of the javascript files, and will give a better indication of where the error is coming from.Stephen HarrisMarch 1, 2017 at 7:59 pm #26336Stephen,
here is the output from console with script_debug enabled:
Uncaught TypeError: Cannot read property ‘tickets’ of undefined
at occurrence-picker.js?ver=1.11.9:628
at Function.m.each.m.forEach (underscore.min.js?ver=1.8.3:5)
at n.each (backbone.min.js?ver=1.2.3:1)
at n.set_ticket_event_availability (occurrence-picker.js?ver=1.11.9:622)
at n.initialize (occurrence-picker.js?ver=1.11.9:504)
at n.e.Model (backbone.min.js?ver=1.2.3:1)
at new n (backbone.min.js?ver=1.2.3:1)
at occurrence-picker.js?ver=1.11.9:937Paul OatenMarch 1, 2017 at 8:22 pm #26337Hi Paul,
It appears to be working for me, with
SCRIPT_DEBUG
enabled. Have you done anything else other than enable script debug?Stephen HarrisMarch 1, 2017 at 8:27 pm #26338It just seems unpredictable.
Do you see the qty field on this page?
https://www.panary.co.uk/craft-baking-courses/2-day-french-with-sourdough/
Paul OatenMarch 1, 2017 at 8:48 pm #26339Yes, and no error in the console. (I had previously seen in the issue before you enabled script debug).
The two scripts should be functionally identical. One is just a compressed version of the other. So I’m surprised that the issue is still not there.
Stephen HarrisMarch 1, 2017 at 8:52 pm #26341Which browser are you using? I’m on Chrome
Paul OatenMarch 1, 2017 at 9:41 pm #26342I haven’t taken any other action except enabling SCRIPT_DEBUG
I just tried loading the original page: https://www.panary.co.uk/craft-baking-courses/1-day-basic/
and I’m now seeing the error again – ie. the field is missing.
Paul OatenMarch 1, 2017 at 10:26 pm #26345I’m using chrome too, and firefox. It’s still working for me.
Based on the error message, it’s clearly having trouble retrieving the occurrence which contains a list of tickets for that occurrence. Try adding:
console.log( parseInt( id, 10 ) ); console.log( this.get('occurrences') ); console.log( result );
To line 416 (line above the return in the
get_occurrence()
). That will give us a bit more information to work with.Stephen HarrisMarch 2, 2017 at 8:41 am #26348Hi Stephen,
I have added those lines.
If you click a few courses from the course calendar page, at some point the qty field should appear and then disappear.
It’s behaving like that on this page for me:
https://www.panary.co.uk/craft-baking-courses/1-day-nordic-germanic/Paul OatenMarch 2, 2017 at 1:25 pm #26352I was able to find an event where I could see this issue, and I’ve determined what is causing it. One some of the events the occurrence IDs, in the json data, are strings not integers.
It’s not clear to me exactly why that is happening for some events, but as a quick fix you can add the following to line 639 of
event-organiser-pro/includes/booking-tickets.php
:foreach ( $remaining_tickets as $occurrence_id => $ticket ) { $remaining_tickets[ $occurrence_id ][ 'id' ] = (int) $ticket['id']; }
To give some context, it should then look like::
//Extract the occurrences we're interested in $remaining_tickets = array_intersect_key( $remaining_tickets , array_flip( $occurrence_ids ) ); foreach ( $remaining_tickets as $occurrence_id => $ticket ) { $remaining_tickets[ $occurrence_id ][ 'id' ] = (int) $ticket['id']; } return $remaining_tickets;
This should fix the issue (though I’ve not been able to replicate it on a test install), but doesn’t explain why some IDs are strings not integers. So I’ll be in touch, if that’s ok, to see if we can some (non-disruptive) investigation the site to establish exactly what’s happening.
Stephen HarrisMarch 2, 2017 at 1:44 pm #26354Hi Stephen,
thanks for that.
I have added the code and spot-checked a few pages and all looks normal.
I also notice that the page loads somewhat faster. Not sure if that’s significant?Very happy to investigate further. I’ll wait to hear from you.
Thanks for the support to get the fix in place.Paul OatenMay 3, 2017 at 8:35 pm #27283Hi Stephen,
I have this same issue again. Probably because I updated the plugin recently and forgot to add the line of code mentioned before to the plugin.
Are you still planning to investigate further?
Paul OatenMay 3, 2017 at 8:47 pm #27284I’ve added the extra lines of code back and it’s fixed for now but only until the next update, obviously.
Paul Oaten -
AuthorPosts