Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1464359

    Hello,
    I’ve installed Woocommerce with my Enfold template and on checkout page, the Order Notes are hidden by default and customers have to click a checkbox to display it.
    I would like to have the textarea visible by default and no checkbox to toggle it.
    Can you help me?
    Thanks,
    Best Regards

    • This topic was modified 3 months, 1 week ago by Empatica.
    #1464400

    Hey Empatica,
    Thanks for your login, first you had a JavaScript error on your site in the child theme file “custom.js” I fix it for you.
    Then I research showing the “order notes” by default, although there are many “solutions” online, I find none work in my test.
    So I added this to your functions.php and it seems to work:

    function auto_click_order_notes_checkbox() {
        ?>
        <script type="text/javascript">
            document.addEventListener('DOMContentLoaded', function() {
                const orderNoteCheckbox = document.querySelector('.woocommerce-checkout .wc-block-checkout__add-note #checkbox-control-0');
                if (orderNoteCheckbox && !orderNoteCheckbox.checked) {
                    orderNoteCheckbox.click();
                }
            });
        </script>
        <?php
    }
    add_action('wp_footer', 'auto_click_order_notes_checkbox');

    Please check.

    For future readers, for some reason the element was different on my test site so I had to use the following, if the above doesn’t work for you try this instead:

    function auto_click_order_notes_checkbox() {
        ?>
        <script type="text/javascript">
            document.addEventListener('DOMContentLoaded', function() {
                const orderNoteCheckbox = document.querySelector('.woocommerce-checkout .wc-block-checkout__add-note #checkbox-control-1');
                if (orderNoteCheckbox && !orderNoteCheckbox.checked) {
                    orderNoteCheckbox.click();
                }
            });
        </script>
        <?php
    }
    add_action('wp_footer', 'auto_click_order_notes_checkbox');

    Best regards,
    Mike

    #1464426

    Thanks Mike,
    It seems to work properly, I’ll do some more testing and let you know if I find an issue.
    Best regards!

    #1464487

    Hey Mike,
    I’ve add the WooPayment addon and the plugin “Order Delivery Date” for the customers to select the delivery date/time.
    And your code stopped working, I’ve tried with the second one, with both together but still didn’t work anymore.
    Do you have any idea?
    I really appreciate your help.
    Thanks
    Best regards!

    #1464509

    Hi,

    Thank you for the update.

    The checkbox “Utilitzeu la mateixa adreça per a la facturació” is checked whenever we view the checkout page, so the script seems to be working as expected. Could you please provide a screenshot of the issue? You can use platforms such as Savvyify, Imgur, or Dropbox to upload and share the screenshot.

    Best regards,
    Ismael

    #1466070

    Hello Ismael,
    Sorry to answer so late, I was out for holidays.
    The checkbox “Utilitzeu la mateixa adreça per a la facturació” is not the one with the issue.
    Check at the bottom of the checkout page, the checkbox “Afegiu una nota a la vostra comanda” I would like to have it checked by default and the Textarea for the customers to write a note displayed by default.
    First it was working with Mike’s code, but after adding the payment method it stopped working.
    Thanks for your help.
    Regards

    #1466079

    Hi,

    Thank you for the clarification.

    We adjusted the edited the functions.php file and adjusted the script a bit. Please make sure to purge the cache before checking.

    function auto_click_order_notes_checkbox() {
        ?>
        <script type="text/javascript">
            jQuery(window).on('load', function() {
                var orderNoteCheckbox = jQuery('.woocommerce-checkout .wc-block-checkout__add-note #checkbox-control-1');
                if (orderNoteCheckbox.length && !orderNoteCheckbox.is(':checked')) {
                    orderNoteCheckbox.click();
                }
            });
        </script>
        <?php
    }
    add_action('wp_footer', 'auto_click_order_notes_checkbox');
    

    Best regards,
    Ismael

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.