Methods
The Vinoshipper object exposes a number of methods to extend your integration.
Window ScopeThese methods are called directly on the
Vinoshipperobject on the top mostWindowobject. While in some caseswindow.Vinoshipermay work, sometimes the focus is set to a different window object.To consistently call the object, we highly suggest calling
window.top.Vinoshipper. This insures you're calling the top most window object at all times.
Core
init
initinit(producerID: number, [options : VinoshipperConfig | undefined]) : Promise<void>
getId () : number | null
producerId: Number, Required
options: See above configuration options.
Initializes the Vinoshipper Injector for use. Returns a Promise<void> allowing for actions after initialization.
render
renderrender() : Promise<void>
Detects all HTML elements and renders Vinoshipper objects that are not yet rendered, except for the Cart and Cart Button.
This function automatically runs with init() unless the setting autoRender is false.
isLoaded
isLoadedisLoaded() : boolean
Returns true if Vinoshipper is loaded. This is different from rendering Vinoshipper components.
isRendered
isRenderedisRendered() : boolean
Returns true if Vinoshipper Cart is rendered. This may also include other elements if autoRender was set to true.
isDebug
isDebugisDebug() : boolean
Returns true if Vinoshipper Injector is in debug mode.
getId
getIdReturns the Producer ID.
getServer
getServergetServer( includeProtocol : boolean = true ) : string | undefined
includeProtocol: Boolean, if false, returns the server string without the protocol (<https://>).
Returns the Vinoshipper server URL string.
getId
getIdgetId () : number | null
Returns the Producer ID.
Cart
getCart
getCartgetCart() : Cart | null
Returns the Vinoshipper Cart object, or null if not defined.
getCartCheckout
getCartCheckoutgetCartCheckout() : URL
Returns an URL object of the Vinoshipper checkout URL for the customer.
getLinkParams
getLinkParamsgetLinkParams (url : URL) : Promise<URL>
Returns the given URL object with any activated Analytics properties for cross-domain tracking. Will return an unaltered URL object if analytics isn't active.
cartOpen
cartOpencartOpen() : void
Opens the Vinoshipper Cart.
cartClose
cartClosecartClose() : void
Closes the Vinoshipper Cart.
Themes
getTheme
getThemegetTheme( withPrefix = false ) : string | null
withPrefix: Boolean, if true returns the CSS class name for the theme.
Returns the class name of the set theme. Returns null if the theme was not defined.
Setting withPrefix will return the theme in the standard Vinoshipper CSS class name.
isThemeDark
isThemeDarkisThemeDark () : boolean
Returns if the set theme is a dark contrast theme. Will return true when theme is set to 'dark', 'red_dark', etc.
Products
onProductAdd
onProductAddonProductAdd (productId : number, qty : number = 1, options : VSCartOnProductAddOptions | undefined = undefined) : Promise<void>
Adds a product to the customer's cart.
productId is the product ID number.
qty the quantity of items to add to the cart (default is 1 item).
options is an optional VSCartOnProductAddOptions object. Setting update: true will overwrite the quantity of the project as set in qty .
export interface VSCartOnProductAddOptions {
update?: boolean
}onProductAddFormSubmit
onProductAddFormSubmitonProductAddFormSubmit(event: SubmitEvent) : Promise<void | Error>
Club Registration
clubRegistrationClubSet
clubRegistrationClubSetclubRegistrationClubSet (clubId : number, domId : string | undefined = undefined) : void
Sets the given club ID to either all rendered Club Registration instances, or to a specific ID.
If domID is not defined, ALL instances of club registration elements will be set to the given club ID.
/** This line sets all currently rendered Club Registration components to a club ID of 1. */
window.top.Vinoshipper.clubRegistrationClubSet(1)
/** This line sets the Club Registration component with the ID "club-registration-main" to a club ID of 1. */
window.top.Vinoshipper.clubRegistrationClubSet(1, 'club-registration-main')If the club ID is not in the list of clubs, the club will not be set and no error will be returned. This can happen when:
- The club ID doesn't exist in the producer account
- The Club Registration element defines the
data-vs-club-allowattribute and does not include the given club ID.
Updated 6 days ago
