Hide a field based on checkbox I want to hide the price for specific products in a product display. I have added a checkbox to the product display type and when it is checked I want to hide the price.

I have figured out that I can hide the field with hide($build['product:commerce_price']) in hook_node_view_alter but the problem is I don't know how to get the value of the checkbox. var_dump($build["field_hide_price"]) outputs null;
The conditional field module will do this for you. In this module when certain fields are selected, get value, ... other operations (hiding,removing,make it required,...) may happen