Yes. The formula for a weapon is:
[(enhancement bonus)^^2 x 2000 ] + 300 + base weapon cost
So, in the case of your hammer, the enhancement bonus is +1, the shock is +1, for a total of +2. Square this for 4, multiply by 2000 equals 8000gp for the magic. The weapon is 300 (for masterwork) plus 12 (base weapon cost) = 312. Total = 8312.
Formula for a deflection magic item is:
(enhancement bonus)^^2 x 2000
So, that's an easy one to figure, +1 protection, squared is 1, multiplied by 2000 = 2000gp.
Different items have different multipliers. For example, cloaks of resistance have a 1000 multiplier, as do stat items. So a cloak of resistance +1 would be 1000gp, and a +2 Str Belt would be 4000gp, for example).