Methods
The Vinoshipper object exposes a number of methods to extend your integration.
Core
init
init
init(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
render
render() : 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
isLoaded
isLoaded() : boolean
Returns true
if Vinoshipper is loaded. This is different from rendering Vinoshipper components.
isRendered
isRendered
isRendered() : boolean
Returns true
if Vinoshipper Cart is rendered. This may also include other elements if autoRender
was set to true
.
isDebug
isDebug
isDebug() : boolean
Returns true
if Vinoshipper Injector is in debug mode.
getId
getId
Returns the Producer ID.
getServer
getServer
getServer( includeProtocol : boolean = true ) : string | undefined
includeProtocol
: Boolean, if false
, returns the server string without the protocol (<https://
>).
Returns the Vinoshipper server URL string.
getId
getId
getId () : number | null
Returns the Producer ID.
Cart
getCart
getCart
getCart() : Cart | null
Returns the Vinoshipper Cart object, or null if not defined.
getCartCheckout
getCartCheckout
getCartCheckout() : URL
Returns an URL object of the Vinoshipper checkout URL for the customer.
getLinkParams
getLinkParams
getLinkParams (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
cartOpen
cartOpen() : void
Opens the Vinoshipper Cart.
cartClose
cartClose
cartClose() : void
Closes the Vinoshipper Cart.
Themes
getTheme
getTheme
getTheme( 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
isThemeDark
isThemeDark () : 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
onProductAdd
onProductAdd (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
onProductAddFormSubmit
onProductAddFormSubmit(event: SubmitEvent) : Promise<void | Error>
Updated about 1 year ago