I’m trying to add dynamic content to my WooCommerce store using the Content Cast code below. Essentially I need the code on each product page with the values in the Javascript code reflecting the product data in WooCommerce – SKU, Brand, Part number, etc.
I’ve looked in to filters, and hooks just not sure how to write it. Any help would be greatly appreciated!
function enqueue_single_product_javascript()
{
if(is_product())
{
<script type='text/javascript'>
var ccs_cc_args = ccs_cc_args || [];
// Product Page
ccs_cc_args.push(['cpn', 'sku']);
ccs_cc_args.push(['mf', 'MANUFACTURER_NAME']);
ccs_cc_args.push(['pn', 'MANUFACTURER_PART_NUMBER']);
ccs_cc_args.push(['upcean', 'UPC_EAN_CODE']);
ccs_cc_args.push(['lang', 'en']);
ccs_cc_args.push(['market', 'US']);
(function () {
var o = ccs_cc_args; o.push(['_SKey', 'ca72adc8']); o.push(['_ZoneId', '97f1b8a61f']);
var sc = document.createElement('script'); sc.type = 'text/javascript'; sc.async = true;
sc.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'cdn.cnetcontent.com/jsc/h.js';
var n = document.getElementsByTagName('script')[0]; n.parentNode.insertBefore(sc, n);
})();
</script>
}
}
add_action('wp_enqueue_scripts', 'enqueue_single_product_javascript');