• Resolved brock40

    (@brock40)


    I’m trying to fetch my product ID for a snippet (HTML tag) for Fera.ai reviews and we’re having issues. We’ve tried:

    <div data-fera-container=”460708″ data-product_id=”<? echo get_the_ID(); ?>”></div>

    and

    <div data-fera-container=”460708″ data-product_id=”<?php echo wc_get_product()->get_id(); ?>”></div>

    Screenshot >> Screenshot to pull up product IDs

    Without any success, anybody know the correct format to fetch product ID from woocommerce product page?

    Thank you

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter brock40

    (@brock40)

    Ok, thanks. I’ll see if I can get this to work.

    Sounds like a plan!

    Please keep us posted and let us know how it goes for you.

    Cheers!

    Thread Starter brock40

    (@brock40)

    I really like Fera.ai reviews system. And I’ve tried quite a few. They have an outdated woocomerce plugin from their Github page. Looks like they abandoned it and are focusing more on Bigcommerce and Shopify unfortunately.

    I’ve reached out to fera.ai, just waiting to hear back if we can fetch the product ID for their Reviews widget with a html tag.

    Mirko P.

    (@rainfallnixfig)

    Sure! Please let us know what they say because it might be of interest to other users as well.

    We’ll be here if you have any further questions.

    Cheers.

    Thread Starter brock40

    (@brock40)

    Greetings again,

    The ball has been kicked into your corner by both fera.ai and my theme developer.

    I need this html tag to pull product ID’s dynamically.

    We’ve tried:

    <div data-fera-container=”460708″ data-product_id=”<? echo wc_get_product( $product_id ); ?>”></div>

    &

    <div data-fera-container=”460708″ data-product_id=”<? echo $product->get_id(); ?>”></div>

    Without any success.

    With either of those html tags, what would you change so it’s able to dynamically get the product number? Or a PHP variable?

    I need the html code to look like this, “?<div data-fera-container=”460708″ data-product_id=”3322″></div>” dynamically of course.

    Right now if I look at the html code it shows code not product id, it should dynamically use product number.

    • This reply was modified 2 years, 10 months ago by brock40.

    Hi @brock40!

    You may need to access the WC Product class to retrieve a product ID since this class handles individual product data.

    All available methods can be found here:

    https://woocommerce.github.io/code-reference/classes/WC-Product.html

    You can also try to use the magic method __toString() on that class, however, since this is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone can chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack.

    We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    My very best,

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘What is the correct format to fetch product ID?’ is closed to new replies.