0

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?

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

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

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

So it would be like this:

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

I´m not sure how to add that into a rule set...

1

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 & enable it....I am suggesting using module as I see you are already checking your condition in code...

  • Yes, I´ll do that instead. Because the variable isn´t available in my rule... It will be much more easier and faster to try the module way. THANKS!! – Rosamunda May 1 '13 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.