script conflict
-
Hi. Hope you are doing great. Thank you for such a great plugin, but I have a problem that looks like a conflict with my script, which consists in showing / removing fields for the invoice depending on whether the checkbox “I want to receive an invoice” is checked or unchecked. The script is located in functions.php. If I disable the “Advanced script rendering” option in your plugin, everything works fine, but the plugin does not block cookies if the user does not consent.
My checkbox on the order page does not work properly until it accepts cookies. Below is a video that shows the problem:
https://vimeo.com/648116789/23a61e7bd7
I would like to ask for quick help because I care about time. The script in functions php consists of the following code:
/** * @snippet Add a Checkbox to Hide/Show Checkout Field - WooCommerce * @how-to Get CustomizeWoo.com FREE * @author Rodolfo Melogli * @compatible WC 4.1 * @donate $9 https://businessbloomer.com/bloomer-armada/ */ add_filter( 'woocommerce_checkout_fields' , 'bbloomer_display_checkbox_and_new_checkout_field' ); function bbloomer_display_checkbox_and_new_checkout_field( $fields ) { $fields['billing']['billing_invoice_ask'] = array( 'type' => 'checkbox', 'label' => __('Checkbox label', 'woocommerce'), 'class' => array('woocommerce-validated'), 'clear' => true ); return $fields; } add_action( 'woocommerce_after_checkout_form', 'bbloomer_conditionally_hide_show_new_field', 9999 ); function bbloomer_conditionally_hide_show_new_field() { wc_enqueue_js( " jQuery('input#billing_invoice_ask').change(function(){ if (! this.checked) { // HIDE IF NOT CHECKED jQuery('#billing_address_1_field').fadeOut(); jQuery('#billing_address_1_field').val(''); jQuery('#billing_last_name_field').fadeOut(); jQuery('#billing_last_name_field').val(''); jQuery('#billing_company_field').fadeOut(); jQuery('#billing_company_field').val(''); jQuery('#billing_vat_number_field').fadeOut(); jQuery('#billing_vat_number_field').val(''); jQuery('#billing_postcode_field').fadeOut(); jQuery('#billing_postcode_field').val(''); jQuery('#billing_city_field').fadeOut(); jQuery('#billing_city_field').val(''); } else { // SHOW IF CHECKED jQuery('#billing_first_name_field').fadeIn(); jQuery('#billing_last_name_field').fadeIn(); jQuery('#billing_company_field').fadeIn(); jQuery('#billing_vat_number_field').fadeIn(); jQuery('#billing_address_1_field').fadeIn(); jQuery('#billing_postcode_field').fadeIn(); jQuery('#billing_city_field').fadeIn(); } }).change(); "); }The page I need help with: [log in to see the link]
The topic ‘script conflict’ is closed to new replies.