• mikiwal1

    (@mikiwal1)


    Hi,

    Could anyone advise, I cannot seem to find a solution how to run,

    this code in only the product pages,

    and also I need a dynamic ID for the product.

    <div id=”…. script src… ?product=ID of the product.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    Hi, can I ask what ‘product’ means on your site? Are you using an ecommerce plugin such as WooCommerce?

    Thread Starter mikiwal1

    (@mikiwal1)

    Yes I’m using woocommerce, need to setup trustmate with a product widget, but I need to supply dynamically the product ID.

    Plugin Author Shea Bunge

    (@bungeshea)

    What’s the full code of the snippet you’re adding? Injecting a <script> tag in the page head?

    Thread Starter mikiwal1

    (@mikiwal1)


    <div id="c1e366a"></div>
    <script defer src="https://trustmate.io/widget/api/123/script?product=PRODUCT_ID"></script>

    Thank you!

    Plugin Author Shea Bunge

    (@bungeshea)

    I’m not super familiar with WooCommerce, but I think this should do the trick:

    add_action( 'wp_head', function () {
    if ( ! function_exists( 'is_product' ) || ! is_product() ) {
    return;
    }

    ?>
    <div id="c1e366a"></div>
    <script defer src="https://trustmate.io/widget/api/123/script?product=<?php the_ID(); ?>>"></script>
    <?php
    } );
Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.