diff --git a/modules/checkout/src/Plugin/Block/CheckoutProgressBlock.php b/modules/checkout/src/Plugin/Block/CheckoutProgressBlock.php index 61e9143cef..cc1127b72e 100644 --- a/modules/checkout/src/Plugin/Block/CheckoutProgressBlock.php +++ b/modules/checkout/src/Plugin/Block/CheckoutProgressBlock.php @@ -3,6 +3,7 @@ namespace Drupal\commerce_checkout\Plugin\Block; use Drupal\commerce_checkout\CheckoutOrderManagerInterface; +use Drupal\commerce_order\Entity\OrderInterface; use Drupal\Core\Block\BlockBase; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Routing\RouteMatchInterface; @@ -79,6 +80,18 @@ public function build() { // The block is being rendered outside of the checkout page. return []; } + + $requested_step_id = $this->routeMatch->getParameter('step'); + return $this->render($order, $requested_step_id); + } + + /** + * Builds the checkout progress block. + * + * @return array + * A render array. + */ + public function render(OrderInterface $order, string $requested_step_id) { $checkout_flow = $this->checkoutOrderManager->getCheckoutFlow($order); $checkout_flow_plugin = $checkout_flow->getPlugin(); $configuration = $checkout_flow_plugin->getConfiguration(); @@ -89,7 +102,6 @@ public function build() { // Prepare the steps as expected by the template. $steps = []; $visible_steps = $checkout_flow_plugin->getVisibleSteps(); - $requested_step_id = $this->routeMatch->getParameter('step'); $current_step_id = $this->checkoutOrderManager->getCheckoutStepId($order, $requested_step_id); $current_step_index = array_search($current_step_id, array_keys($visible_steps)); $index = 0; diff --git a/modules/checkout/src/Plugin/Commerce/CheckoutPane/ContactInformation.php b/modules/checkout/src/Plugin/Commerce/CheckoutPane/ContactInformation.php index 2791b75537..01e6dacf0b 100644 --- a/modules/checkout/src/Plugin/Commerce/CheckoutPane/ContactInformation.php +++ b/modules/checkout/src/Plugin/Commerce/CheckoutPane/ContactInformation.php @@ -2,6 +2,7 @@ namespace Drupal\commerce_checkout\Plugin\Commerce\CheckoutPane; +use Drupal\commerce_order\Entity\OrderInterface; use Drupal\Core\Form\FormStateInterface; /** @@ -70,6 +71,9 @@ public function submitConfigurationForm(array &$form, FormStateInterface $form_s * {@inheritdoc} */ public function isVisible() { + if (!$this->order instanceof OrderInterface) { + return FALSE; + } // Show the pane only for guest checkout. return empty($this->order->getCustomerId()); } diff --git a/modules/payment/src/Plugin/Commerce/CheckoutPane/PaymentProcess.php b/modules/payment/src/Plugin/Commerce/CheckoutPane/PaymentProcess.php index f60f91f2bd..6475f71f5d 100644 --- a/modules/payment/src/Plugin/Commerce/CheckoutPane/PaymentProcess.php +++ b/modules/payment/src/Plugin/Commerce/CheckoutPane/PaymentProcess.php @@ -5,6 +5,7 @@ use Drupal\commerce\InlineFormManager; use Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow\CheckoutFlowInterface; use Drupal\commerce_checkout\Plugin\Commerce\CheckoutPane\CheckoutPaneBase; +use Drupal\commerce_order\Entity\OrderInterface; use Drupal\commerce_payment\Exception\DeclineException; use Drupal\commerce_payment\Exception\PaymentGatewayException; use Drupal\commerce_payment\Plugin\Commerce\PaymentGateway\ManualPaymentGatewayInterface; @@ -129,6 +130,9 @@ public function submitConfigurationForm(array &$form, FormStateInterface $form_s * {@inheritdoc} */ public function isVisible() { + if (!$this->order instanceof OrderInterface) { + return FALSE; + } if ($this->order->isPaid() || $this->order->getTotalPrice()->isZero()) { // No payment is needed if the order is free or has already been paid. return FALSE;