woocommerce product id for variations code example
Example 1: woocommerce get product id
global $product;
$product->get_id();
Example 2: get product price by id woocommerce snippet
/**
* Get product price by product ID.
*/
function wc_get_product_price( $product_id ) {
return ( $product = wc_get_product( $product_id ) ) ? $product->get_price() : false;
}