admin管理员组文章数量:1130349
In the single woocommerce page where I have actions like woocommerce_before_single_product_summary to show the products, I can't access the product id. I tried the following codes and it didn't work :
$post->ID
get_the_ID()
$product->id
$product->get_id()
In the single woocommerce page where I have actions like woocommerce_before_single_product_summary to show the products, I can't access the product id. I tried the following codes and it didn't work :
$post->ID
get_the_ID()
$product->id
$product->get_id()
Share
Improve this question
asked Nov 5, 2018 at 13:51
AmiritionAmirition
3555 silver badges20 bronze badges
1 Answer
Reset to default 1If you're using $product and $post, then you need to use global $product; and global $post to get access to them. Did you do that?
global $product;
$product_id = $product->get_id();
In the single woocommerce page where I have actions like woocommerce_before_single_product_summary to show the products, I can't access the product id. I tried the following codes and it didn't work :
$post->ID
get_the_ID()
$product->id
$product->get_id()
In the single woocommerce page where I have actions like woocommerce_before_single_product_summary to show the products, I can't access the product id. I tried the following codes and it didn't work :
$post->ID
get_the_ID()
$product->id
$product->get_id()
Share
Improve this question
asked Nov 5, 2018 at 13:51
AmiritionAmirition
3555 silver badges20 bronze badges
1 Answer
Reset to default 1If you're using $product and $post, then you need to use global $product; and global $post to get access to them. Did you do that?
global $product;
$product_id = $product->get_id();
本文标签: can39t get the product id in single woocommerce page
版权声明:本文标题:can't get the product id in single woocommerce page 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749204503a2332334.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论