Is this snippet modification correct? (php snippet in a drupal commerce rule) I´ve read about the possibility to use this snippet to hide a specific checkout pane (in Drupalcommerce), according to the cart contents.

Could I use this somewhat modified to hide a pane when the user completing the order is registered?

&lt;?php
function hook_commerce_checkout_pane_info_alter(&amp;$checkout_pane) {
    foreach ($checkout_pane as $pane_name =&gt; &amp; $pane_data) {
        if ($pane_name == 'customer_profile_shipping') {
            $order = commerce_cart_order_load($user-&gt;uid);
            if (!empty($order-&gt;data)) {
                    unset($checkout_pane['customer_profile_shipping']);
}}}}
?&gt;


I understand that I should change this if (!empty($order-&gt;data)) { maybe to something like this? if ($user-&gt;uid &gt; 0) {

Is that correct? I want tu hide the pofile2 pane:

So it would be like this:

&lt;?php
function hook_commerce_checkout_pane_info_alter(&amp;$checkout_pane) {
    foreach ($checkout_pane as $pane_name =&gt; &amp; $pane_data) {
        if ($pane_name == 'customer_profile_shipping') {
            $order = commerce_cart_order_load($user-&gt;uid);
            if ($user-&gt;uid &gt; 0) {
                    unset($checkout_pane['commerce_p2cp_profile']);
}}}}
?&gt;


I´m not sure how to add that into a rule set...
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...