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
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.
change:item - when an item is added/changed on the order
change:discount - when the discount/promo code changes
change:payplan - when the selected payment plan changes
change:order - when the order changes/total is recalculated
change: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 URL
value: 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 hide
index: Int - the index of the Item's option
status: 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 select
paypal - PayPal payment method
stripe - credit card via Stripe
expressPay - 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 hide
indexes: Int|Array - Index or array of indexes of the options you want to hide
Payment Method
method: String - payment method to hide/show
paypal - PayPal payment method
stripe - credit card via Stripe
expressPay - ApplePay and other express pay options when available