Closed kkmuffme closed 5 years ago
This plugin don't support templating languages (as stated in the README). The <?php
"tag" is considered as malformed JS code. What you could do is something like this:
var contentInfos;
// <?php echo "\ncontentInfos = " . json_encode(get_content_infos()); ?>
if (contentInfos) {
//adding fbq value on add to cart button click
fbq( 'track', 'AddToCart', contentInfos);
}
function get_content_infos() {
$fbpixelid = get_option('wc_settings_tag_manager_fbpixelid');
//this script is use to facebook pixel id
if (isset($fbpixelid) && !empty($fbpixelid)) {
return [
'content_ids' => $product_id,
'content_type' => 'product',
'value' => $product_price,
'currency' => get_woocommerce_currency(),
]
} else {
return null
}
}
But I am using plugin php-markup ( https://www.npmjs.com/package/eslint-plugin-php-markup ) which converts all <? ... ?> to 0, so there shouldn't be an issue with that? Or is this a bug with the php-markup plugin? (then I should probably open a issue here https://github.com/tengattack/eslint-plugin-php-markup/issues )
Allright I didn't know about php-markup, thanks for pointing this out. So php-markup is replacing every php parts to '0', so basically:
function valueAddedToCart( final_result ) {
dataLayer.push({
'event': 'addToCart',
'eventCategory': 'Ecommerce',
'eventAction': 'Add to Cart',
'eventLabel': 'Click Add to Cart Product Page',
'eventValue': undefined,
'currencyCode': '0',
'ecommerce': {
'currencyCode': '0',
'add': {
'products': final_result
}
}
});
0
//adding fbq value on add to cart button click
fbq( 'track', 'AddToCart', {
'content_ids': '0',
'content_type': 'product',
'value': '0',
'currency': '0'
});
0
} // this is line 1040
The line 1028 is indeed under-indented and is an unused expression, and lacks an ending semi colon. Same goes for the line 1039.
Thanks, now its clear. Already opened an issue in the other repo for it with a suggestion on how to fix it.
I have this code:
Gives these errors which are completely wrong:
Setup configuration