Buy Buttons Manager

The Voog.buyButtonsManager object handles all interactions with buy buttons on the page. This includes selecting product variants and clicks on buy buttons to add products to the shopping cart. 


init(languageCode: string)

This method initializes the buy button manager with the given language code.
languageCode — the current page's language code, used for translations.

refreshSelectedVariants(button: HTMLElement)

This method updates all variant dropdowns to reflect the currently selected state — it updates all options that are out of stock and removes those that are disabled. This is useful when you need to change the dropdown values manually and need to update all the other ones as well.
button — the DOM node that contains the dropdowns and button (.edy-buy-button-view)

setState(button: HTMLElement, status: 'enabled' | 'disabled')
This method disables or enables the given button, adding or removing required classes and setting the disabled attribute for the <button> element.

 — the DOM node that contains the dropdowns and button (.edy-buy-button-view)
status —  either "enabled" or "disabled"

setPrice(button: HTMLElement, price: ?number | ?string)
This method explicitly sets the button's price text if it is configured to show it. The store's VAT is automatically calculated and added to the total and the text is formatted to include the current store's currency symbol or code.

button — the HTMLElement that contains the dropdowns and button (.edy-buy-button-view)
price — the subtotal amount

setPickedVariants(button: HTMLElement, variants: ?{ [number]: [number] })
Updates or removes the button's data-product object.

button — the HTMLElement that holds the dropdowns and button (.edy-buy-button-view)
variants — An object representing the picked variants. Eacy variant type's ID is used as a key and its corresponding variant value ID is used as the value, e.g { 1: 3, 2: 4 }. If left blank, the values are instead taken from the currently selected options in the variant dropdowns.


  detail: product — updated product object, buyButton - buy button object.