diff --git a/modules/checkout/config/install/commerce_checkout.commerce_checkout_flow.default.yml b/modules/checkout/config/install/commerce_checkout.commerce_checkout_flow.default.yml index 63e6be7..c350ab2 100644 --- a/modules/checkout/config/install/commerce_checkout.commerce_checkout_flow.default.yml +++ b/modules/checkout/config/install/commerce_checkout.commerce_checkout_flow.default.yml @@ -6,6 +6,7 @@ label: Default plugin: multistep_default configuration: display_checkout_progress: true + display_checkout_progress_breadcrumb_links: false panes: login: allow_guest_checkout: true diff --git a/modules/checkout/config/schema/commerce_checkout.schema.yml b/modules/checkout/config/schema/commerce_checkout.schema.yml index 63d6063..aaf7713 100644 --- a/modules/checkout/config/schema/commerce_checkout.schema.yml +++ b/modules/checkout/config/schema/commerce_checkout.schema.yml @@ -38,6 +38,9 @@ commerce_checkout_flow_with_panes_configuration: display_checkout_progress: type: boolean label: 'Display checkout progress' + display_checkout_progress_breadcrumb_links: + type: boolean + label: 'Display checkout progress breadcrumb links' order_summary_view: type: string label: 'Order summary view' diff --git a/modules/checkout/src/Plugin/Block/CheckoutProgressBlock.php b/modules/checkout/src/Plugin/Block/CheckoutProgressBlock.php index 61e9143..bdeb2a6 100644 --- a/modules/checkout/src/Plugin/Block/CheckoutProgressBlock.php +++ b/modules/checkout/src/Plugin/Block/CheckoutProgressBlock.php @@ -4,6 +4,7 @@ namespace Drupal\commerce_checkout\Plugin\Block; use Drupal\commerce_checkout\CheckoutOrderManagerInterface; use Drupal\Core\Block\BlockBase; +use Drupal\Core\Link; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Routing\RouteMatchInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -109,9 +110,23 @@ class CheckoutProgressBlock extends BlockBase implements ContainerFactoryPluginI continue; } + // Create breadcrumb style links for active checkout steps. + if ( + $configuration['display_checkout_progress_breadcrumb_links'] && + $index <= $current_step_index + ) { + $label = Link::createFromRoute($step_definition['label'], 'commerce_checkout.form', [ + 'commerce_order' => $order->id(), + 'step' => $step_id, + ])->toString(); + } + else { + $label = $step_definition['label']; + } + $steps[] = [ 'id' => $step_id, - 'label' => $step_definition['label'], + 'label' => $label, 'position' => $position, ]; } diff --git a/modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowBase.php b/modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowBase.php index 352ee67..8b82efa 100644 --- a/modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowBase.php +++ b/modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowBase.php @@ -235,6 +235,7 @@ abstract class CheckoutFlowBase extends PluginBase implements CheckoutFlowInterf public function defaultConfiguration() { return [ 'display_checkout_progress' => TRUE, + 'display_checkout_progress_breadcrumb_links' => FALSE, ]; } @@ -248,6 +249,12 @@ abstract class CheckoutFlowBase extends PluginBase implements CheckoutFlowInterf '#description' => $this->t('Used by the checkout progress block to determine visibility.'), '#default_value' => $this->configuration['display_checkout_progress'], ]; + $form['display_checkout_progress_breadcrumb_links'] = [ + '#type' => 'checkbox', + '#title' => $this->t('Display checkout progress breadcrumb as links'), + '#description' => $this->t('Let the checkout progress block render the breadcrumb as links.'), + '#default_value' => $this->configuration['display_checkout_progress_breadcrumb_links'], + ]; return $form; } @@ -265,6 +272,7 @@ abstract class CheckoutFlowBase extends PluginBase implements CheckoutFlowInterf $values = $form_state->getValue($form['#parents']); $this->configuration = []; $this->configuration['display_checkout_progress'] = $values['display_checkout_progress']; + $this->configuration['display_checkout_progress_breadcrumb_links'] = $values['display_checkout_progress_breadcrumb_links']; } } diff --git a/modules/checkout/templates/commerce-checkout-progress.html.twig b/modules/checkout/templates/commerce-checkout-progress.html.twig index 0771032..b0a9276 100644 --- a/modules/checkout/templates/commerce-checkout-progress.html.twig +++ b/modules/checkout/templates/commerce-checkout-progress.html.twig @@ -14,6 +14,6 @@ #}