Overview
Spiffy Checkout JavaScript interface API
The JS Interface API enables you to tap into your checkout's data and modify things via custom code directly on your checkout.
The JavaScript Interface API is different from SpiffyJS which is used for embedding and interacting with Spiffy Elements. This interface API may be introduced into SpiffyJS in the future but in the meantime this is available on your checkouts via custom code.
checkout.ready()
All of your custom code that uses this interface needs to be wrapped in a ready
call so it runs AFTER the checkout is interactable
checkout.data
This is the main way to access the current state of the checkout. Access checkout data any time within checkout.ready
including inside events to inform any of your custom logic.
checkout.on()
Add event listeners to checkout events
Available Events
change:field
- when a field value is changedchange:item
- when an item is added/changed on the orderchange:discount
- when the discount/promo code changeschange:payplan
- when the selected payment plan changeschange:order
- when the order changes/total is recalculatedchange:paymethod
- when the selected payment method changes
checkout.set()
Change fields and selections on the checkout
Fields
name: String
- field name, this is the same name that would be used to set the field via the URLvalue: String
- the value to set the field to
Items
block_id: Int
- block ID that this item exists on as an Option. This can be found by inspecting the block element you're looking to hideindex: Int
- the index of the Item's optionstatus: Boolean
- optional, default: false - whether we are adding/removing this item
Payment Plan
id: Int
- optional, default: null - ID of the payment plan to select, null/undefined will set it to single-pay
Discount
code: String
- optional, default: null - promo code to apply, null will remove the currently applied promo
Payment Method
method: String
- payment method to selectpaypal
- PayPal payment methodstripe
- credit card via StripeexpressPay
- ApplePay and other express pay options when available
checkout.show()/hide()
Hide/show elements on the checkout easily – this can always be done via CSS so this is just a shorthand approach to hiding block, sections, and options.
Sections
section_id
: Int
- ID of the section to hide. This can be found by inspecting the section element you're looking to hide
Blocks
block_id
: Int
- ID of the block to hide. This can be found by inspecting the block element you're looking to hide
Options
block_id
: Int
- ID of the block to hide. This can be found by inspecting the block element you're looking to hideindexes: Int|Array
- Index or array of indexes of the options you want to hide
Payment Method
method: String
- payment method to hide/showpaypal
- PayPal payment methodstripe
- credit card via StripeexpressPay
- ApplePay and other express pay options when available
Last updated