Woocommerce, get current product id
2017 Update - since WooCommerce 3:
global $product;$id = $product->get_id();
Woocommerce doesn't like you accessing those variables directly. This will get rid of any warnings from woocommerce if your wp_debug is true.
If the query hasn't been modified by a plugin for some reason, you should be able to get a single product page's "id" via
global $post;$id = $post->ID
OR
global $product;$id = $product->id;
EDIT: As of WooCommerce 3.0 this needs to be
global $product;$id = $product->get_id();
Since WooCommerce 2.2
you are able to simply use the wc_get_product
Method. As an argument you can pass the ID
or simply leave it empty if you're already in the loop.
wc_get_product()->get_id();
OR with 2 lines
$product = wc_get_product();$id = $product->get_id();