Current page ID on WooCommerce page in WordPress

php, woocommerce, wordpress

Solution

It might be too late, but i was trying to get the same result as you and this below worked pretty well for me:

<?php 
  if(is_shop()){
    $page_id = woocommerce_get_page_id('shop');
  }else{
    $page_id = $post->ID;
  }
?>

Hope this will help you.

Problem

I am using a WooCommerce plugin for WordPress. Now in a file page.php I am trying to get the current opened page id via `$post->ID` and `the_id()` but all I am getting is the product ID and not the current page ID. Probably because WooCommerce overwrites the loop ? What can I do ?

Original source