How to disable add to cart button when had a color change

Here the issue is If the logo upload option is selected and then if the user select the color option, the ‘Add to cart’ button will be enabled without uploading the image. The ‘Add to cart’ button should be disabled as long the logo upload option is selected without uploading an image. so we have add a delay function to prevent this

_.delay(() => {
                                if (currentID === 'custcol_ag_checkcolors') {
                                    let logoSelectionBox = this.model.get('custcol_ag_logooptionselectbox');
                                    let logoImage = $("#in-modal-fileuploadfield").val();
                                    let isCheckUpladedURL = document.getElementById("in-modal-set-liquid-pixel-logo-url") ? document.getElementById("in-modal-set-liquid-pixel-logo-url").innerHTML : undefined;
                                    if (logoSelectionBox && logoSelectionBox !== '' && logoImage === '') {
                                        $('#in-modal-upload-logo-button').show();
                                        $('.cart-add-to-cart-button-button').prop('disabled', true);
                                    } else if (logoImage !== '' && logoSelectionBox !== '') {
                                        $('#in-modal-upload-logo-button').show();
                                        $('.cart-add-to-cart-button-button').prop('disabled', false);
                                    } else {
                                        $('.cart-add-to-cart-button-button').prop('disabled', false);
                                    }
                                    if (logoSelectionBox !== '') {
                                        if (isCheckUpladedURL || !isCheckUpladedURL) {
                                            $('.cart-add-to-cart-button-button').prop('disabled', false);
                                        } else {
                                            $('.cart-add-to-cart-button-button').prop('disabled', true);
                                        }
                                    }
                                    if (e.currentTarget.value === existingValue) {
                                        $('.cart-add-to-cart-button-button').prop('disabled', true);
                                    }
                                }
                            }, 150);

Leave a comment

Your email address will not be published. Required fields are marked *