Title: WP_Scripts::localize
Last modified: March 27, 2021

---

# WP_Scripts::localize

 *  Resolved [faca5](https://wordpress.org/support/users/faca5/)
 * (@faca5)
 * [5 years ago](https://wordpress.org/support/topic/wp_scriptslocalize/)
 * Hello.
 * Plugin “WooCommerce Google Ads Conversion Tracking” is not compatible with latest
   version of WordPress 5.7.0.
 * Error:
    Notice: WP_Scripts::localize je bil zahtevan nepravilno. The $l10n parameter
   must be an array. To pass arbitrary data to scripts, use the wp_add_inline_script()
   function instead. Prosimo preberite Debugging in WordPress za več informacij.(
   To sporočilo je bilo dodano v izdaji 5.7.0.)
 * File:
    plugins/woocommerce-google-adwords-conversion-tracking-tag/classes/pixels/
   class-google-pixel-manager.php
 * Line:
    wooptpmDataLayer[‘visible_products’] = <!DOCTYPE html>
 *  wooptpmDataLayer[‘visible_products’] = <?php
    echo json_encode( $this->eec_get_visible_products(
   $visible_product_ids ) ) ;
 * Please can you fix?

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

 *  Thread Starter [faca5](https://wordpress.org/support/users/faca5/)
 * (@faca5)
 * [5 years ago](https://wordpress.org/support/topic/wp_scriptslocalize/#post-14242165)
 * Solution!
 * Add if(gettype($product) == ‘object’) {.
 *     ```
       private function eec_get_visible_products( $product_ids ) : array
           {
               $data = [];
               $position = 1;
               foreach ( $product_ids as $key => $product_id ) {
                   $product = wc_get_product( $product_id );
       			if(gettype($product) == 'object') {
       				$data[$product->get_id()] = [
       					'id'       => (string) $product->get_id(),
       					'sku'      => (string) $product->get_sku(),
       					'name'     => (string) $product->get_name(),
       					'price'    => (string) $product->get_price(),
       					'brand'    => $this->get_brand_name( $product->get_id() ),
       					'category' => (array) $this->get_product_category( $product->get_id() ),
       					'quantity' => (int) 1,
       					'position' => (int) $position,
       				];
       				$position++;
       			}
               }
               return $data;
           }
       ```
   
 *  Thread Starter [faca5](https://wordpress.org/support/users/faca5/)
 * (@faca5)
 * [5 years ago](https://wordpress.org/support/topic/wp_scriptslocalize/#post-14242166)
 * Problem was related with 1 product which wasn’t object.
 *  Plugin Author [alekv](https://wordpress.org/support/users/alekv/)
 * (@alekv)
 * [5 years ago](https://wordpress.org/support/topic/wp_scriptslocalize/#post-14242250)
 * Hi [@faca5](https://wordpress.org/support/users/faca5/)
 * This has already been fixed in our development environment and will be released
   with the next version in the next few days.
 * Regards
    Aleks

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

The topic ‘WP_Scripts::localize’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce-google-adwords-conversion-tracking-tag/assets/
   icon-256x256.png?rev=2704744)
 * [Pixel Manager for WooCommerce – Conversion Tracking, Google Ads, GA4, TikTok, Dynamic Remarketing](https://wordpress.org/plugins/woocommerce-google-adwords-conversion-tracking-tag/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-google-adwords-conversion-tracking-tag/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-google-adwords-conversion-tracking-tag/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-google-adwords-conversion-tracking-tag/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-google-adwords-conversion-tracking-tag/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-google-adwords-conversion-tracking-tag/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [alekv](https://wordpress.org/support/users/alekv/)
 * Last activity: [5 years ago](https://wordpress.org/support/topic/wp_scriptslocalize/#post-14242250)
 * Status: resolved