How do I get the product ID when I submit the form? How do I get the product ID when I submit the form?



I have http://localhost/drupalcart/product/7?v=7 as URL. I need to get that 7 when I click on Add to cart.

(The form doesn't come from a third-party, but it's something I made.)
Hi guys finally i got the solution to it, all that I need it was the following:

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


then I got the product id of the product i am checking it