Skip to content

Commit

Permalink
Issue #2906028 by mglaman: Add theme suggestions for the checkout ord…
Browse files Browse the repository at this point in the history
…er summary and completion message templates
  • Loading branch information
mglaman authored and mglaman committed Sep 18, 2017
1 parent f1665ea commit a15509b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
30 changes: 30 additions & 0 deletions modules/checkout/commerce_checkout.module
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,46 @@ 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().
*/
function commerce_checkout_theme_suggestions_commerce_checkout_form(array $variables) {
$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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down

0 comments on commit a15509b

Please sign in to comment.