Change permalink for custom_post_type using custom_post_meta (woocommerce)

The $post in your callback handler is an object, and object properties, like variables, are case sensitive. So you have to use $post->ID, not $post->id.

The question here is: How can we prevent errors like this one during development?

For objects, there is a simple solution: use type hinting and an IDE that makes use of it.

If you change the signature of your callback handler to this …

function eli_changeProductLink($permalink, \WP_Post $post)

… an IDE like PHPStorm or Eclipse will suggest the correct property names while you are typing:

IDE screenshot

The second lesson we can take from this: Use a consistent naming scheme for your own variables and properties, unlike WordPress which is mixing uppercase and lowercase, underscore and hyphens in names. Sticking to just one scheme will make the life of others easier when they have to work with your code.