function commerce_payment_validate_checkout_flow in Commerce Core 8.2
Validate callback for the checkout flow form.
Prevents users from putting the PaymentInformation and PaymentProcess panes on the same step, which would result in an infinite loop.
1 string reference to 'commerce_payment_validate_checkout_flow'
- commerce_payment_form_commerce_checkout_flow_edit_form_alter in modules/
payment/ commerce_payment.module - Implements hook_form_FORM_ID_alter().
File
- modules/
payment/ commerce_payment.module, line 203 - Provides payment functionality.
Code
function commerce_payment_validate_checkout_flow(array $form, FormStateInterface $form_state) {
$pane_configuration = $form_state
->getValue([
'configuration',
'panes',
]);
if (!isset($pane_configuration['payment_information'], $pane_configuration['payment_process'])) {
return;
}
$payment_information_step = $pane_configuration['payment_information']['step_id'];
$payment_process_step = $pane_configuration['payment_process']['step_id'];
if ($payment_information_step !== '_disabled' && $payment_information_step === $payment_process_step) {
$form_state
->setError($form, t('<em>Payment information</em> and <em>Payment process</em> panes need to be on separate steps.'));
}
}