If you want to get Product id from order id in Woocommerce then fetch order details.
$order = new WC_Order( $order_id ); $items = $order->get_items();
then if you loop through them, you can get all the relevant data:
foreach ( $items as $item ) { $product_name = $item['name']; $product_id = $item['product_id']; $product_variation_id = $item['variation_id']; }
Have any doubt, then comment here!
Notice: Undefined variable: order_id in E:\xampp\htdocs\demos\wp-content\plugins\wpjit-restrict\include\enqueue.php on line 81
Hi Zaheer Abbas,
You have assign order id to $order_id.
Ex. $order_id=’2456′;