Skip to content

Commit a15509b

Browse files
mglamanmglaman
authored andcommitted
Issue #2906028 by mglaman: Add theme suggestions for the checkout order summary and completion message templates
1 parent f1665ea commit a15509b

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

modules/checkout/commerce_checkout.module

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,46 @@ function commerce_checkout_theme() {
4545
return $theme;
4646
}
4747

48+
/**
49+
* Implements hook_theme_suggestions_HOOK().
50+
*/
51+
function commerce_checkout_theme_suggestions_commerce_checkout_completion_message(array $variables) {
52+
/** @var \Drupal\commerce_checkout\Entity\CheckoutFlowInterface $checkout_flow */
53+
$checkout_flow = $variables['order_entity']->get('checkout_flow')->entity;
54+
$original = $variables['theme_hook_original'];
55+
$suggestions = [];
56+
$suggestions[] = $original;
57+
$suggestions[] = $original . '__' . $checkout_flow->getPluginId();
58+
$suggestions[] = $original . '__' . $checkout_flow->id();
59+
}
60+
61+
/**
62+
* Implements hook_theme_suggestions_HOOK().
63+
*/
64+
function commerce_checkout_theme_suggestions_commerce_checkout_order_summary(array $variables) {
65+
/** @var \Drupal\commerce_checkout\Entity\CheckoutFlowInterface $checkout_flow */
66+
$checkout_flow = $variables['order_entity']->get('checkout_flow')->entity;
67+
$original = $variables['theme_hook_original'];
68+
$suggestions = [];
69+
$suggestions[] = $original;
70+
$suggestions[] = $original . '__' . $checkout_flow->getPluginId();
71+
$suggestions[] = $original . '__' . $checkout_flow->id();
72+
}
73+
4874
/**
4975
* Implements hook_theme_suggestions_HOOK().
5076
*/
5177
function commerce_checkout_theme_suggestions_commerce_checkout_form(array $variables) {
5278
$original = $variables['theme_hook_original'];
5379
$suggestions = [];
5480
$suggestions[] = $original;
81+
$suggestions[] = $original . '__' . $variables['form']['#plugin_id'];
82+
$suggestions[] = $original . '__' . $variables['form']['#entity_id'];
5583
// If the checkout form has a sidebar, suggest the enhanced layout.
5684
if (isset($variables['form']['sidebar']) && Element::isVisibleElement($variables['form']['sidebar'])) {
5785
$suggestions[] = $original . '__with_sidebar';
86+
$suggestions[] = $original . '__' . $variables['form']['#plugin_id'] . '__with_sidebar';
87+
$suggestions[] = $original . '__' . $variables['form']['#entity_id'] . '__with_sidebar';
5888
}
5989

6090
return $suggestions;

modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowBase.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ public function buildForm(array $form, FormStateInterface $form_state, $step_id
257257

258258
$steps = $this->getVisibleSteps();
259259
$form['#tree'] = TRUE;
260+
$form['#entity_id'] = $this->entityId;
261+
$form['#plugin_id'] = $this->pluginId;
260262
$form['#step_id'] = $step_id;
261263
$form['#title'] = $steps[$step_id]['label'];
262264
$form['#theme'] = ['commerce_checkout_form'];

0 commit comments

Comments
 (0)