This seems pretty ugly, it would be nice to have an access callback instead - unless there's a better way?
/**
* Decide whether to display the organisation info pane.
*/
function ve_subscriptions_commerce_checkout_pane_info_alter(&$checkout_panes) {
$subscription_type = NULL;
$pane = 'commerce_fieldgroup_pane__group_organisation_details|commerce_order|commerce_order|form';
$checkout_panes[$pane]['name'] = t('Organisation details');
// Check we're in the process of checking out
if (arg(0) === 'checkout' && is_numeric(arg(1)) && $order = commerce_order_load(arg(1))) {
// Load the order and verify it contains an organisation product
$wrapper = entity_metadata_wrapper('commerce_order', $order);
foreach ($wrapper->commerce_line_items as $product) {
$subscription_type = $product->commerce_product->field_commerce_subscription_type->value();
if ($subscription_type === 'organisation') {
break;
}
}
// If we don't have an organisation, disable the checkout pane.
if ($subscription_type !== 'organisation') {
$checkout_panes[$pane]['enabled'] = FALSE;
}
}
}
Closed: outdated
1.0
Developer experience