modules/acm_checkout/src/Plugin/CheckoutFlow/CheckoutFlowBase.php
protected function processStepId($requested_step_id) {
    $cart = $this->cartStorage;

    // Redirect back to cart page if cart is empty.
    if ($cart->isEmpty()) {
      throw new NeedsRedirectException(Url::fromRoute('acm_cart.cart')->toString());
    }

    $cart_step_id = $cart->getCheckoutStep();
    $step_ids = array_keys($this->getVisibleSteps());
    $step_id = $requested_step_id;
    if (empty($step_id) || !in_array($step_id, $step_ids)) {
      // Take the step ID from the cart, or default to the first one.
      $step_id = $cart_step_id;
      if (empty($step_id)) {
        $step_id = reset($step_ids);
      }
    }

    $config = $this->getConfiguration();
    $validate_current_step = $config['validate_current_step'];
    if (empty($validate_current_step)) {
      return $step_id;
    }

    // If user is on a certain step in their cart, check that the step being
    // processed is not further along in the checkout process then their last
    // completed step. If they haven't started the checkout yet, make sure they
    // can't get past the first step.
    $step_index = array_search($step_id, $step_ids);
    if (empty($cart_step_id)) {
      $first_step = reset($step_ids);
      if ($step_index > $first_step) {
        return $this->redirectToStep($first_step);
      }
    }
    else {
      $cart_step_index = array_search($cart_step_id, $step_ids);
      // Step being processed is further along than they should be, redirect
      // back to step they still need to complete.
      if ($step_index > $cart_step_index) {
        return $this->redirectToStep($cart_step_id);
      }
    }

    return $step_id;
  }
protected function processStepId($requested_step_id) {
    $cart = $this->cartStorage;

    // Redirect back to cart page if cart is empty.
    if ($cart->isEmpty()) {
      throw new NeedsRedirectException(Url::fromRoute('acm_cart.cart')->toString());
    }

    $cart_step_id = $cart->getCheckoutStep();
    $step_ids = array_keys($this->getVisibleSteps());
    $step_id = $requested_step_id;
    if (empty($step_id) || !in_array($step_id, $step_ids)) {
      // Take the step ID from the cart, or default to the first one.
      $step_id = $cart_step_id;
      if (empty($step_id)) {
        $step_id = reset($step_ids);
      }
    }

    $config = $this->getConfiguration();
    $validate_current_step = $config['validate_current_step'];
    if (empty($validate_current_step)) {
      return $step_id;
    }

    // If user is on a certain step in their cart, check that the step being
    // processed is not further along in the checkout process then their last
    // completed step. If they haven't started the checkout yet, make sure they
    // can't get past the first step.
    $step_index = array_search($step_id, $step_ids);
    if (empty($cart_step_id)) {
      $first_step = reset($step_ids);
      if ($step_index > $first_step) {
        return $this->redirectToStep($first_step);
      }
    }
    else {
      $cart_step_index = array_search($cart_step_id, $step_ids);
      // Step being processed is further along than they should be, redirect
      // back to step they still need to complete.
      if ($step_index > $cart_step_index) {
        return $this->redirectToStep($cart_step_id);
      }
    }

    return $step_id;
  }
protected function processStepId ( $ requested_step_id ) { $ cart = $ this -> cartStorage ; // Redirect back to cart page if cart is empty. if ( $ cart -> isEmpty ( ) ) { throw new NeedsRedirectException ( Url :: fromRoute ( 'acm_cart.cart' ) -> toString ( ) ) ; } $ cart_step_id = $ cart -> getCheckoutStep ( ) ; $ step_ids = array_keys ( $ this -> getVisibleSteps ( ) ) ; $ step_id = $ requested_step_id ; if ( empty ( $ step_id ) || ! in_array ( $ step_id , $ step_ids ) ) { // Take the step ID from the cart, or default to the first one. $ step_id = $ cart_step_id ; if ( empty ( $ step_id ) ) { $ step_id = reset ( $ step_ids ) ; } } $ config = $ this -> getConfiguration ( ) ; $ validate_current_step = $ config [ 'validate_current_step' ] ; if ( empty ( $ validate_current_step ) ) { return $ step_id ; } // If user is on a certain step in their cart, check that the step being // processed is not further along in the checkout process then their last // completed step. If they haven't started the checkout yet, make sure they // can't get past the first step. $ step_index = array_search ( $ step_id , $ step_ids ) ; if ( empty ( $ cart_step_id ) ) { $ first_step = reset ( $ step_ids ) ; if ( $ step_index > $ first_step ) { return $ this -> redirectToStep ( $ first_step ) ; } } else { $ cart_step_index = array_search ( $ cart_step_id , $ step_ids ) ; // Step being processed is further along than they should be, redirect // back to step they still need to complete. if ( $ step_index > $ cart_step_index ) { return $ this -> redirectToStep ( $ cart_step_id ) ; } } return $ step_id ; }
Processes the requested step ID.

@param string $requested_step_id
The step ID.

@return string
The processed step ID.

@throws NeedsRedirectException
Throws exception when cart is empty.
Processes the requested step ID .