Hi ken ,
FYI, custom coding is out of the scope of our support.
The code in the article is provided as is. We don't provide support for it.
Anyway, in these lines should be the response:
$product_id = isset( $row['_variation_id'] ) ? $row['_variation_id'] : 0;
if ( ! $product_id && isset( $row['_product_id'] ) ) {
$product_id = $row['_product_id'];
}
If the product in the order item is a variation, it should take the parent product ID. You should find out whether these fields exist in your database. No additional responses regarding this will be provided. I suggest contacting a good developer if you can't figure out where the problem is.
Best Regards,
José Andrés