• Resolved badlydrawnben

    (@badlydrawnben)


    Hi Thomas,

    I’m using the latest version (1.61) of the plugin. I’m getting a js error in the console on many single product pages because their category has an apostrophe in it. The apostrophe isn’t being escaped so I get this in my HTML source:

    
    var gtm4wp_product_detail_data = {
    		name: 'Not Just Surfers Tee',
    		id: 0,
    		price: 0,
    		category: 'Men's T-shirts',
    		variant: ''
    	};

    Is there something I can do at my end to fix it?
    Example product page here: https://bit.ly/2so9s7w

    Thanks,
    Ben

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Thomas Geiger

    (@duracelltomi)

    Hi Ben,

    Thanks for letting me know this bug.
    You are right, the category name is not being escaped properly here.

    If you can edit the plugin files, please locate woocommerce.php under integration dir in my plugin folder.

    Search for the string: gtm4wp_product_detail_data
    Change this one line:

    var gtm4wp_product_detail_data = {
    name: ‘” . gtm4wp_woocommerce_html_entity_decode( get_the_title() ) . “‘,
    id: 0,
    price: 0,
    category: ‘” . esc_js( $product_cat ) . “‘,
    variant: ”
    };

    Please le me know whether this fixed the error message so that I can include the fix in the next plugin version.

    Thanks,
    Thomas Geiger

    • This reply was modified 7 years, 5 months ago by Thomas Geiger.
    Thread Starter badlydrawnben

    (@badlydrawnben)

    Hi Thomas,

    Thanks for the quick reply.

    Yes – I’ve applied that edit to the plugin file and I can confirm that it does fix the problem.

    Best wishes,
    Ben

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Woo product category with apostrophe throws error’ is closed to new replies.