Last active
October 5, 2015 22:16
-
-
Save salsalabs/d83dacf69cd79e30afbb to your computer and use it in GitHub Desktop.
Scripts to add an "Add additonal guests" button to events after an attendee has checked out. The button appears at the end of the "you're already signed up" version of an event page. This version appears when an attendee is already registered. Having this script in place allows more guests (and revenue) than without.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
// Script to add an "Add Additional Guests" button on events after | |
// the attendee has already checked out. | |
// See https://salsasupport.zendesk.com/entries/69943210 | |
// | |
(function() { | |
if (Request.getURL().indexOf('event/common/public/') == -1) { | |
return; | |
} | |
var event_KEY = Request.getParameter('event_KEY'); | |
if (event_KEY == null) { | |
return; | |
} | |
var event = DB.getObject('event', event_KEY); | |
if (event == null) { | |
return; | |
} | |
if (event.Allow_Guest_Signup != 1) { | |
return; | |
} | |
var supporter_KEY = Supporter.supporter_KEY; | |
if (supporter_KEY == null) { | |
return; | |
} | |
var supporter_events = DB.getObjects('supporter_event', { | |
conditions: [ | |
new Condition('supporter_KEY', '=', supporter_KEY), | |
new Condition('event_KEY', '=', event_KEY) | |
], | |
includes: ['supporter_event_KEY'], | |
limit: 1 | |
}); | |
var supporter_event_KEY = 'null'; | |
if (supporter_events.length == 0) { | |
return; | |
} else { | |
supporter_event_KEY = supporter_events[0].supporter_event_KEY; | |
} | |
?> | |
<script type='text/javascript'> | |
// Script to append an "Add additional guests" button to an event. | |
// This script won't appear unless the current page is an event page. | |
// | |
$(function() { | |
if (window.location.href.indexOf('receipt') != -1) { | |
return; | |
} | |
if (window.location.href.indexOf('guestReg') != -1) { | |
return; | |
} | |
if (window.location.href.indexOf('checkout.sjs?event_KEY=') != -1) { | |
$('#processPostForm').append($('#add-guest-inputs').children()); | |
return; | |
} | |
if ($('#regForm').length > 0) { | |
$('#regForm').after($('#addGuestDiv')); | |
} else { | |
$('#salsa').after($('#addGuestDiv')); | |
} | |
}); | |
</script> | |
<div style="display: none"> | |
<div id="addGuestDiv"> | |
<input type="button" value="Add Additional Guests" | |
onclick="document.location='guestReg.sjs?supporter_event_KEY=<?= supporter_event_KEY ?>&event_KEY=<?= event_KEY ?>'" ?> | |
</div> | |
</div> | |
<div id="add-guest-inputs" style="display: none"> | |
<input type="hidden" name="event_KEY" value="<?= event_KEY ?>"/> | |
<input type="hidden" name="supporter_event_KEY" value="<?= supporter_event_KEY ?>"/> | |
<input type="hidden" name="supporter_KEY" value="<?= supporter_KEY ?>"/> | |
<input type="hidden" name="key" value="<?= supporter_KEY ?>"/> | |
</div> | |
<? | |
})(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment