hook_checkoutapi(&$txn, $op, $arg3 = NULL, $arg4 = NULL)
ecommerce-4-7/docs/developer/hooks/core.php, line 66
Manipulate the checkout process, including injecting form pages.
Checkoutapi can be implemented by any module. It can be used to insert a page into into the checkout process and even validate/save the form data. Another feature of the API is the ability to push data onto the final review page before final checkout. Note that the order of the form pages is controlled via http://example.com/index.php?q=admin/store/checkout
&$txn The transaction object for an order. This keeps growing in data from screen to screen.
$op What kind of action is being performed. Possible values:
This varies depending on the operation.
<?php
function hook_checkoutapi(&$txn, $op, $arg3 = NULL, $arg4 = NULL) {
$output = '';
switch ($op) {
case 'form':
if ($form = payment_view_methods()) {
drupal_set_title(t('Please select a payment method'));
$form[] = array(
'#type' => 'submit',
'#value' => t('Continue'),
);
return $form;
}
else {
foreach (payment_get_methods() as $module) {
if (module_invoke($module, 'paymentapi', $edit, 'display name')) {
$txn->payment_method = $module;
break;
}
}
return false;
}
case 'validate':
if (!$txn->payment_method) {
form_set_error('payment_method', t('Please choose a payment method.'));
}
break;
case 'save':
$txn->screen++;
break;
case 'review':
$form['payment'] = array('#value' => module_invoke($txn->payment_method, 'paymentapi', $txn, 'display name'));
return $form;
case 'review_validate':
break;
case 'review_save':
break;
}
}
?>