Is this snippet modification correct? (php snippet in a drupal commerce rule)
You can add your PHP code in action of some rules. For this you will have to enable core PHP filter module.
Once you enable it, you go to ADD ACTION in rules and you will find a option "Execute custom PHP code". If the variable you are suppose to use is available there for using with the PHP code then it will work without any problem..

As per your requirement, if you do this by simple small module then also it will work fine as you just have to put this hook in your .module file, declare the module in .info file &amp; enable it....I am suggesting using module as I see you are already checking your condition in code...