PHP Pass Thank You Page Product Data Using jQuery Script in WooCommerce

Add this PHP code to your child themes functions file to get the product data for every sale from your thank you page.

The order object contains all the order data you can use in jQuery or PHP.

Here’s the output you can view in the source code or console screen when you inspect the output:

You can also pass customer product data like the product ID & price like this :

Outputs the values for the data passed from PHP code to jQuery in simple text using json format on the customers Thank You page.