Helper Methods
Ordergroove’s offers library registers a global variable, og.offers, that contains a number of useful helper methods.
addOptinChangedCallback
Registers a callback function that is invoked when a user either opts in or opts out of a product offer. Returns the offers module object to enable method chaining.
Arguments
Node/Webpack
clear
Clears the opt-ins from the browser’s local storage. This method should be called upon successful checkout.
config
Configures the library options for advanced usage or customization. Returns the offers module object to enable method chaining.
Arguments
configObject JSON Schema
disableOptinChangedCallbacks
Disables all callback functions registered via addOptinChangedCallback.
getOptins
Returns a serialized representation of the products that have been opted in to by the customer, in the format expected by Ordergroove’s Purchase POST endpoint. The optional productIds argument is an array of product IDs for which to return the serialized opt-ins. If not supplied, all opt-ins are returned.
Note that getOptins represents the customer’s action of opting in, not simply whether a product is set to “Default to Subscription”. A default-to-subscription product will not appear in getOptins unless the customer has also clicked the opt-in button.
Arguments
initialize
Initializes the library. In UMD, this is called as og.offers(...) directly. Returns the offers module object to enable method chaining.
Arguments
setLocale
Configures the library locale text. Returns the offers module object to enable method chaining.