Fix the call to id function in wocommerce product wordpress

The following code isn’t working. And it says “Function id was called incorrectly”

<a href="http://www.amazon.com/gp/product/<?php echo get_post_meta( $product->id , '_amzASIN', true );?>/?tag=solomon09-20" class="button" target="_blank">MORE INFORMATION</a>

Wordpress 6.6.1, PHP 8.2

The code was working with previous versions of woocommerce, wordpress, and on PHP 7.2 etc. Not working with latest versions.

The code extracts amazon ASIN for a particular product from its metadata, and inserts in the above to generate a url.

The issue you’re encountering is due to changes in WooCommerce and WordPress functions over time. The id property of the $product object has been deprecated. Instead, you should use the get_id() method to retrieve the product ID.

Here’s how you can update your code:

<a href="http://www.amazon.com/gp/product/<?php echo get_post_meta( $product->get_id(), '_amzASIN', true ); ?>/?tag=solomon09-20" class="button" target="_blank">MORE INFORMATION</a>