0

I created two checkboxes i magento checkout in billing address section. Checkboxes name "Firma" and "Osoba prywatna". My custom module allow me to create only checkboxes but I would like to uncheck "firma" checkbox when i check "osoba prywatna" checkbox and the other way too. example

I was trying use jquery code but it's not working.

    jQuery(document).ready( function() { 
        $('[name="custom_attributes[faktura_os_prywatna]"]').prop('checked', true);
            $('[name="custom_attributes[is_business_account]"], [name="custom_attributes[faktura_os_prywatna]"]').on('change', function() {
                $('[name="custom_attributes[is_business_account]"], [name="custom_attributes[faktura_os_prywatna]"]').not(this).prop('checked', false);  
            });
        });
    });

Do you have any ideas?

1
  • why not use radio buttons instead? Commented Mar 15, 2021 at 9:26

1 Answer 1

0

I set timeout and now it's working fine


require(['jquery', 'jquery/ui'], function ($) {

    setTimeout(function () {

        $(document).ready(function () {
            alert('Working');
            $('#checkmo').prop('checked', true);
            $('[name="custom_attributes[faktura_os_prywatna]"]').prop('checked', true);
            $('[name="custom_attributes[is_business_account]"], [name="custom_attributes[faktura_os_prywatna]"]').on('change', function () {
                $('[name="custom_attributes[is_business_account]"], [name="custom_attributes[faktura_os_prywatna]"]').not(this).prop('checked', false);
            });
        });
    }, 5000);
});


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.