function commerce_license_complete_checkout_form in Commerce License 7
Checkout pane callback: License completion message.
Outputs a pane for each found license. Synchronizable licenses are shown in a pane that refreshes itself periodically (every 2s by default), allowing the customer to follow the synchronization process. If the license doesn't get synchronized within $refresh_timeout seconds (60s by default), the refresh process is stopped, and the license synchronization is marked as failed.
File
- includes/
commerce_license.checkout_pane.inc, line 75 - Checkout pane callbacks.
Code
function commerce_license_complete_checkout_form($form, &$form_state, $checkout_pane, $order) {
$pane_form = array(
'#type' => 'container',
);
$balance = commerce_payment_order_balance($order);
$order_paid = $balance && $balance['amount'] <= 0;
$js_attached = FALSE;
// Show a pane for each found license.
$licenses = commerce_license_get_order_licenses($order);
foreach ($licenses as $license) {
$synchronizable = $license instanceof CommerceLicenseSynchronizableInterface;
// If this is a synchronizable license, attach the JS for the refresh.
if (!$js_attached && $synchronizable) {
$pane_form['#attached']['library'][] = array(
'system',
'drupal.ajax',
);
$pane_form['#attached']['js'] = array(
drupal_get_path('module', 'commerce_license') . '/commerce_license.js',
);
$js_attached = TRUE;
}
// Get the message to show.
$message = t('Your license will be activated once your payment has been processed.');
if ($order_paid) {
$refresh = $synchronizable ? TRUE : FALSE;
$message = commerce_license_checkout_competion_message($license, $refresh);
}
$title_arguments = array(
'@product_title' => $license->wrapper->product->title
->value(),
);
$pane_form[$license->license_id] = array(
'#type' => $checkout_pane['fieldset'] ? 'fieldset' : 'container',
'#title' => t('License information - @product_title', $title_arguments),
'#collapsible' => $checkout_pane['collapsible'],
'#collapsed' => $checkout_pane['collapsed'],
'output' => array(
'#markup' => $message,
),
);
}
return $pane_form;
}