How do I add a custom class to a field based on another field value(boolean)?
I've never used the commerce module but that sounds possible, you need to create a module for the hook to be triggered from.

Then, with the devel module installed use dpm($build, $type) within the hook to see the correct names (I've put in dummy values in CAPS) and do something like:

function MYMODULE_entity_view_alter(&amp;$build, $type){
  if ($type =='product') {
    if (isset($build['SALE_PRICE']['VALUE'])) {
                $build['PRICE']['attributes']['class'] = array('on-sale');
            }
        }
    }