Checkouts

Checkouts are scoped based on their URL which means you can access the checkout object at any time by using the checkout(url, [configObj]) method (see method docs). If the checkout exists on the page it will access that instance or create a new instance

spiffy.on('ready', function () {
    // find or create an instance of this checkout
    spiffy.checkout("https://yourcompany.spiffy.co/checkout/test-checkout")
})

Checkouts have shared instances. Meaning if you have the same checkout on the same page multiple times, any changes you make to the settings of one of them will affect all of them (eg, applying a discount).

This makes having multiple popups or a mixture of popups and an inline checkout easy to customize and manage.

Accessing a checkout instance should only be done within the ready event to ensure SpiffyJS is fully mounted

Updating Settings

When you're getting a checkout instance you can also pass in a settings object to make changes directly to that checkout instance:

spiffy.on('ready', function () {
    // find or create an instance of this checkout
    spiffy.checkout("https://yourcompany.spiffy.co/checkout/test-checkout", {
        // set customer info
        customer: {
            email: 'jon@snow.com',
            name_first: 'Jon',
            name_last: 'Snow',
        }
    })
})

Last updated