Methods
The Vinoshipper object exposes a number of methods to extend your integration.
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>
Updated 2 months ago
