How to get current product id from custom block?
Use this below code to get product ID

$product_id = \Drupal::routeMatch()-&gt;getParameter('commerce_product')-&gt;id(); 


and then return the value in custom block,

return [      
      '#product_id' =&gt;  $product_id,
    ];