Skip to content

Instantly share code, notes, and snippets.

@AllanPooley
Last active July 1, 2021 02:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AllanPooley/077a549d4ed65aa2cf5d270f2ed678d1 to your computer and use it in GitHub Desktop.
Save AllanPooley/077a549d4ed65aa2cf5d270f2ed678d1 to your computer and use it in GitHub Desktop.
Eventbrite Embedded Checkout Snippet
import $ from 'jquery'
const initEventbrite = () => new Promise((resolve) => {
const ready = () => {
resolve(window.EBWidgets)
}
let first = true
const init = () => {
if (window.EBWidgets && window.EBWidgets.createWidget) {
ready()
} else if (first) {
first = false
$(init)
} else {
setTimeout(init, 50)
}
}
init()
})
// base options for the eventbrite widget
const ebOptions = {
widgetType: 'checkout'
}
const initIFrame = (eventId) => {
const containerId = 'eventbrite-widget-container'
const $eventbriteContainer = $(`#${containerId}`)
if ($eventbriteContainer.length) {
initEventbrite().then((EBWidgets) => {
EBWidgets.createWidget({
...ebOptions,
eventId: eventId,
iframeContainerId: containerId,
iframeContainerHeight: 800
})
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment