diff --git a/modules/checkout/commerce_checkout.module b/modules/checkout/commerce_checkout.module index a792b11b34..e29fa02eef 100644 --- a/modules/checkout/commerce_checkout.module +++ b/modules/checkout/commerce_checkout.module @@ -45,6 +45,32 @@ function commerce_checkout_theme() { return $theme; } +/** + * Implements hook_theme_suggestions_HOOK(). + */ +function commerce_checkout_theme_suggestions_commerce_checkout_completion_message(array $variables) { + /** @var \Drupal\commerce_checkout\Entity\CheckoutFlowInterface $checkout_flow */ + $checkout_flow = $variables['order_entity']->get('checkout_flow')->entity; + $original = $variables['theme_hook_original']; + $suggestions = []; + $suggestions[] = $original; + $suggestions[] = $original . '__' . $checkout_flow->getPluginId(); + $suggestions[] = $original . '__' . $checkout_flow->id(); +} + +/** + * Implements hook_theme_suggestions_HOOK(). + */ +function commerce_checkout_theme_suggestions_commerce_checkout_order_summary(array $variables) { + /** @var \Drupal\commerce_checkout\Entity\CheckoutFlowInterface $checkout_flow */ + $checkout_flow = $variables['order_entity']->get('checkout_flow')->entity; + $original = $variables['theme_hook_original']; + $suggestions = []; + $suggestions[] = $original; + $suggestions[] = $original . '__' . $checkout_flow->getPluginId(); + $suggestions[] = $original . '__' . $checkout_flow->id(); +} + /** * Implements hook_theme_suggestions_HOOK(). */ @@ -52,9 +78,13 @@ function commerce_checkout_theme_suggestions_commerce_checkout_form(array $varia $original = $variables['theme_hook_original']; $suggestions = []; $suggestions[] = $original; + $suggestions[] = $original . '__' . $variables['form']['#plugin_id']; + $suggestions[] = $original . '__' . $variables['form']['#entity_id']; // If the checkout form has a sidebar, suggest the enhanced layout. if (isset($variables['form']['sidebar']) && Element::isVisibleElement($variables['form']['sidebar'])) { $suggestions[] = $original . '__with_sidebar'; + $suggestions[] = $original . '__' . $variables['form']['#plugin_id'] . '__with_sidebar'; + $suggestions[] = $original . '__' . $variables['form']['#entity_id'] . '__with_sidebar'; } return $suggestions; diff --git a/modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowBase.php b/modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowBase.php index 4df1347f59..268ca106cd 100644 --- a/modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowBase.php +++ b/modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowBase.php @@ -257,6 +257,8 @@ public function buildForm(array $form, FormStateInterface $form_state, $step_id $steps = $this->getVisibleSteps(); $form['#tree'] = TRUE; + $form['#entity_id'] = $this->entityId; + $form['#plugin_id'] = $this->pluginId; $form['#step_id'] = $step_id; $form['#title'] = $steps[$step_id]['label']; $form['#theme'] = ['commerce_checkout_form'];