Do not add shipping handlers when option is checked

This commit is contained in:
Narek Zakarian 2024-05-22 21:02:42 +04:00
parent 5e2218685c
commit 8301da1550
No known key found for this signature in database
GPG key ID: 07AFD7E7A9C164A7

View file

@ -91,20 +91,26 @@ class Renderer {
let venmoButtonClicked = false; let venmoButtonClicked = false;
const buttonsOptions = () => { const buttonsOptions = () => {
return { const options = {
style, style,
...contextConfig, ...contextConfig,
onClick: this.onSmartButtonClick, onClick: this.onSmartButtonClick,
onInit: (data, actions) => { onInit: (data, actions) => {
if (this.onSmartButtonsInit) { if (this.onSmartButtonsInit) {
this.onSmartButtonsInit(data, actions); this.onSmartButtonsInit(data, actions);
} }
this.handleOnButtonsInit(wrapper, data, actions); this.handleOnButtonsInit(wrapper, data, actions);
}, },
onShippingOptionsChange: (data, actions) => this.shouldHandleShippingInPaypal(venmoButtonClicked) ? handleShippingOptionsChange(data, actions, this.defaultSettings) : null, };
onShippingAddressChange: (data, actions) => this.shouldHandleShippingInPaypal(venmoButtonClicked) ? handleShippingAddressChange(data, actions, this.defaultSettings) : null,
// Check the condition and add the onShippingOptionsChange handler if needed
if (this.shouldHandleShippingInPaypal(venmoButtonClicked)) {
options.onShippingOptionsChange = (data, actions) => handleShippingOptionsChange(data, actions, this.defaultSettings);
options.onShippingAddressChange = (data, actions) => handleShippingAddressChange(data, actions, this.defaultSettings);
} }
}
return options;
};
jQuery(document) jQuery(document)
.off(this.reloadEventName, wrapper) .off(this.reloadEventName, wrapper)