I doubt I need to say this to you, but for the sake of other reading the thread - hitting a dog for any reason at all is abhorrent and I am disgusted by people who do and who think it is acceptable. People who hit animals shouldn't own animals.
Hitting dogs is not training in any way shape or form. It is abuse and will create a fearful, more dangerous dog in many cases.
I trained my dog not to bark by consistently getting in front of her, making eye contact, putting my finger to my lips and saying the word "quiet". When she was quiet I praised her, when she barked I repeated the behaviour until she understood what I wanted from her. It is as simple as being consistent and learning to 'speak dog'. If she was trying to show me something I would let her know I'd seen it and that she'd done her 'job'.
Now, just the word quiet, or the cue of me putting my finger to my lips will stop her barking.