arch-8.x-1.x-dev/modules/checkout/arch_checkout.module

modules/checkout/arch_checkout.module
<?php
/**
 * @file
 * ARCH Checkout module file.
 */

use Drupal\Core\Template\Attribute;

/**
 * Implements hook_theme().
 */
function arch_checkout_theme() {
  return [
    'arch_checkout_complete' => [
      'variables' => [
        'order' => NULL,
        'message' => NULL,
        'message_extra' => NULL,
        'checkout_complete_info' => NULL,
      ],
    ],
  ];
}

/**
 * Preprocess arch checkout summary theme.
 *
 * @param array $variables
 *   Variables array.
 */
function template_preprocess_arch_checkout_complete(array &$variables) {
  /** @var \Drupal\arch_order\Entity\OrderInterface $order */
  $order =& $variables['order'];

  $variables['attributes'] = new Attribute($variables['attributes']);
  $variables['attributes']->addClass('checkout-complete-message');

  $variables['#cache']['max-age'] = 0;
  $variables['#cache']['contexts'][] = 'user';
  $variables['#cache']['contexts'][] = 'session';
  $variables['#cache']['tags'] = $order->getCacheTags();
}

/**
 * Implements hook_preprocess_HOOK() for HTML document templates.
 */
function arch_checkout_preprocess_html(&$variables) {
  if (\Drupal::routeMatch()->getRouteName() === 'arch_checkout.complete') {
    $variables['attributes']['class'][] = 'path-checkout-complete';
  }
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc