You are here

public function CheckoutFlowBase::getPreviousStepId in Commerce Core 8.2

Gets the previous step ID for the given step ID.

Note that we’re not calling getVisibleSteps() on purpose here to bypass its static caching which may no longer be valid due to previous panes altering the order.

Parameters

string $step_id: The step ID.

Return value

string|null The previous step, or NULL if there is none.

Overrides CheckoutFlowInterface::getPreviousStepId

1 call to CheckoutFlowBase::getPreviousStepId()
CheckoutFlowBase::actions in modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowBase.php
Builds the actions element for the current form.

File

modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowBase.php, line 157

Class

CheckoutFlowBase
Provides the base checkout flow class.

Namespace

Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow

Code

public function getPreviousStepId($step_id) {
  $step_ids = array_keys($this
    ->getSteps());
  $previous_step_index = array_search($step_id, $step_ids) - 1;
  while (isset($step_ids[$previous_step_index])) {
    if (!$this
      ->isStepVisible($step_ids[$previous_step_index])) {
      $previous_step_index--;
      continue;
    }
    return $step_ids[$previous_step_index];
  }
  return NULL;
}