In all cases of foreclosure of mortgages and in all other cases in which attorneys' fees are allowed, the amount thereof shall be fixed by the court at such sum as the court shall deem reasonable, any stipulations in the note, mortgage or other instrument to the contrary notwithstanding; but in no case shall said fee be fixed above contract price stated in said note or contract.