SpiffyJS
  • SpiffyJS
    • Overview
    • Config
    • Elements
    • Methods
    • Events
    • Checkouts
      • Settings
      • Methods
      • Events
    • Affiliates
  • JavaScript API (beta)
    • Overview
    • Examples
  • Examples
    • Full Page Loader
    • Dynamically Apply Discounts
  • REST API
  • Back to Spiffy
Powered by GitBook
On this page

Was this helpful?

  1. SpiffyJS

Checkouts

PreviousEventsNextSettings

Last updated 2 years ago

Was this helpful?

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 (). 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 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',
        }
    })
})

settings object
see method docs