If 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();
If 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();