• Resolved xszejdi

    (@xszejdi)


    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]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author webtoffee

    (@webtoffee)

    Hi @xszejdi,

    Greetings from Webtoffee!

    We can see the facebook’s script and the check box-related scripts are merged into a single script tag. So it is blocked under the Faceboook pixel’s category.

    If you can separate (eg: add it as inline) the script from facebook’s script, it would solve the issue.

    Thread Starter xszejdi

    (@xszejdi)

    Hi. Unfortunately, I don’t know how to add a pixel script in a separate tag because I use the “Facebook for WordPress” plugin. Can I put the checkbox script in a different tag instead? if so, can you help me convert my PHP snippet (placed above by me) to make it work?

    Best,
    Matthew.

    Plugin Author webtoffee

    (@webtoffee)

    Hi @xszejdi,

    Then please try deactivating that plugin and adding the Facebook tracking script directly via any of the cookie categories. You will find the field to insert script under GDPR Cookie Consent > Cookie Category > Edit page.

    Thread Starter xszejdi

    (@xszejdi)

    It works. You’re the best. Thank you.

    Plugin Author webtoffee

    (@webtoffee)

    Hi @xszejdi,

    That’s great. If you like our plugin and support, please leave us a review.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘script conflict’ is closed to new replies.