javascript - Adding Hidden Validation-Only Fields to WooCommerce Checkout - Stack Overflow

admin2025-04-17  2

I have a problem with WooCommerce. I’m trying to add additional fields that will function only as validation. I don't want them to appear in the order summary, emails, etc. These are my example checkboxes, but I also have others that hide depending on whether someone selects something. Later in the summary, if not selected, it shows "No," and I don't want that to be visible at all. This is the new block-based WooCommerce.

woocommerce_register_additional_checkout_field(
    array(
        'id'       => 'namespace/agree-terms',
        'label'    => 'I agree to the terms and conditions',
        'location' => 'order',
        'type'     => 'checkbox',
    )
);

woocommerce_register_additional_checkout_field(
    array(
        'id'       => 'namespace/agree-marketing',
        'label'    => 'I agree to receive marketing emails',
        'location' => 'order',
        'type'     => 'checkbox',
    )
);
转载请注明原文地址:http://anycun.com/QandA/1744860845a88647.html