Archived topic
Retrieve Product ID dynamically with a hook element or PHP variable
5 replies · Started by Brent on January 31, 2022
So, I finally found a review system I like called Fera.ai. But, it doesn't offer a native plugin, although it does give you the code for your site. Unfortunately, their site is more focused with shopify and Wix at the moment. They have an outdated Woocommerce plugin from 2019 on their Github.
Anyhow, they give you the footer code which works just fine creating a hook element for all pages.
Second, they give you the code in which I created a hook element to display on all product pages.
The codes we have tried are, "div data-fera-container="460708" data-product_id="<? echo $product->get_id(); ?>">
"
and, "div data-fera-container="460708" data-product_id="<? echo wc_get_product( $product_id ); ?>">
"
The issue is the Product ID needs to change dynamically for each unique Product ID or a PHP variable.
I have 35 products, as of right now and the only way I am able to get this to work is if I get the Product ID for each of my 35 products and create a hook element for each individually.
Is there a way to create one hook element that will dynamically pull each product ID? Creating 35 hooks seems rather tedious.
This is a copy and paste from Fera.ai and customer support email below.
right now if you see html code it shows code not product id, it should dynamically use product number.
For example for product
https://genx.bio/product/sr9009
it should be, "div data-fera-container="460708" data-product_id="3322"></div"