• Resolved pluginswoo

    (@pluginswoo)


    HI there,

    I’ve using this plugin Variation Swatches plugin: https://wordpress.org/plugins/woo-variation-swatches/

    When the swatches plugin is activated only script loads in the following way.

    <script id='woo-variation-swatches-js-extra'>
    var woo_variation_swatches_options = {"is_product_page":"1","show_variation_label":"1","variation_label_separator":":","wvs_nonce":"a5e6a41143","archive_image_selector":".wvs-attachment-image","archive_product_wrapper":".wvs-pro-product","archive_add_to_cart_button_selector":"","is_archive_ajax_add_to_cart":"1","clickable_out_of_stock":"","enable_catalog_mode":"","linkable_attribute":"","enable_single_variation_preview":"","enable_single_variation_preview_archive":"","single_variation_preview_attribute":"","enable_linkable_variation_url":"","show_variation_stock_info":"","stock_label_display_threshold":"5","wc_bundles_enabled":"","product_permalink":"https:\/\/wptestbox.com\/martin\/?product=arrastre-de-madera"};
    </script>

    But when your plugins is activated it loads in the following way

    <script type="text/plain" class="cmplz-script" id='woo-variation-swatches-js-extra'>
    var woo_variation_swatches_options = {"is_product_page":"1","show_variation_label":"1","variation_label_separator":":","wvs_nonce":"a5e6a41143","archive_image_selector":".wvs-attachment-image","archive_product_wrapper":".wvs-pro-product","archive_add_to_cart_button_selector":"","is_archive_ajax_add_to_cart":"1","clickable_out_of_stock":"","enable_catalog_mode":"","linkable_attribute":"","enable_single_variation_preview":"","enable_single_variation_preview_archive":"","single_variation_preview_attribute":"","enable_linkable_variation_url":"","show_variation_stock_info":"","stock_label_display_threshold":"5","wc_bundles_enabled":"","product_permalink":"https:\/\/wptestbox.com\/martin\/?product=arrastre-de-madera"};
    </script>

    Why is that happening?

    Thank you

    • This topic was modified 5 years, 1 month ago by pluginswoo.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Aert

    (@aahulsebos)

    Hi @pluginswoo,

    The fix: add this to your functions.php:

    function cmplz_whitelist_my_string( $class, $total_match, $found ) {
    	$string = 'woo-variation-swatches-js-extra'; //'string from inline script or source that should be whitelisted'
    	if ( $found && false !== strpos( $total_match, $string ) ) {
    		$class = 'cmplz-native'; // add cmplz-script for Marketing and cmplz-stats for Statistics
    	}
    	return $class;
    }
    add_filter ( 'cmplz_script_class', 'cmplz_whitelist_my_string', 10 , 3 );

    Or as a MU plugin you can add this php file: https://github.com/Really-Simple-Plugins/complianz-integrations/blob/master/whitelist-script.php with woo-variation-swatches-js-extra as ‘my-string’.

    The why: I think the WooCommerce Analytics integration is triggered on ‘add_to_cart_button’. The above will fix it, we will fix at our end so this script ID is always skipped.

    Hope his helps,
    regards Aert

    • This reply was modified 5 years, 1 month ago by Aert. Reason: spelling
    Plugin Contributor Jarno Vos

    (@jarnovos)

    Hello @pluginswoo,

    Has the suggestion above fixed your issue? I’m closing this thread for now, but please reach out to us if you require any further assistance.

    Kind regards,
    Jarno

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Swatches not loading wp_localize_script() when your plugin is activated’ is closed to new replies.