class OrderSummary in Commerce Core 8.2
Provides the Order summary pane.
Plugin annotation
@CommerceCheckoutPane(
id = "order_summary",
label = @Translation("Order summary"),
default_step = "_sidebar",
wrapper_element = "container",
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\commerce_checkout\Plugin\Commerce\CheckoutPane\CheckoutPaneBase implements CheckoutPaneInterface, ContainerFactoryPluginInterface
- class \Drupal\commerce_checkout\Plugin\Commerce\CheckoutPane\OrderSummary implements CheckoutPaneInterface
- class \Drupal\commerce_checkout\Plugin\Commerce\CheckoutPane\CheckoutPaneBase implements CheckoutPaneInterface, ContainerFactoryPluginInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of OrderSummary
File
- modules/
checkout/ src/ Plugin/ Commerce/ CheckoutPane/ OrderSummary.php, line 17
Namespace
Drupal\commerce_checkout\Plugin\Commerce\CheckoutPaneView source
class OrderSummary extends CheckoutPaneBase implements CheckoutPaneInterface {
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [
'view' => '',
] + parent::defaultConfiguration();
}
/**
* {@inheritdoc}
*/
public function buildConfigurationSummary() {
if ($this->configuration['view']) {
$view_storage = $this->entityTypeManager
->getStorage('view');
$view = $view_storage
->load($this->configuration['view']);
if ($view) {
return $this
->t('View: @view', [
'@view' => $view
->label(),
]);
}
}
else {
return $this
->t('View: Not used');
}
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
$form['use_view'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Use a View to display the order summary'),
'#description' => $this
->t('Overrides the checkout order summary template with the output of a View.'),
'#default_value' => !empty($this->configuration['view']),
];
$view_storage = $this->entityTypeManager
->getStorage('view');
$available_summary_views = [];
/** @var \Drupal\views\Entity\View $view */
foreach ($view_storage
->loadMultiple() as $view) {
if (strpos($view
->get('tag'), 'commerce_order_summary') !== FALSE) {
$available_summary_views[$view
->id()] = $view
->label();
}
}
$form['view'] = [
'#type' => 'select',
'#title' => $this
->t('View'),
'#options' => $available_summary_views,
'#default_value' => $this->configuration['view'],
'#required' => TRUE,
'#states' => [
'visible' => [
':input[name="configuration[panes][order_summary][configuration][use_view]"]' => [
'checked' => TRUE,
],
],
],
];
return $form;
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::submitConfigurationForm($form, $form_state);
if (!$form_state
->getErrors()) {
$values = $form_state
->getValue($form['#parents']);
$this->configuration['view'] = NULL;
if ($values['use_view']) {
$this->configuration['view'] = $values['view'];
}
}
}
/**
* {@inheritdoc}
*/
public function buildPaneForm(array $pane_form, FormStateInterface $form_state, array &$complete_form) {
if ($this->configuration['view']) {
$pane_form['summary'] = [
'#type' => 'view',
'#name' => $this->configuration['view'],
'#display_id' => 'default',
'#arguments' => [
$this->order
->id(),
],
'#embed' => TRUE,
];
}
else {
$pane_form['summary'] = [
'#theme' => 'commerce_checkout_order_summary',
'#order_entity' => $this->order,
'#checkout_step' => $complete_form['#step_id'],
];
}
return $pane_form;
}
/**
* {@inheritdoc}
*/
public function submitPaneForm(array &$pane_form, FormStateInterface $form_state, array &$complete_form) {
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CheckoutPaneBase:: |
protected | property | The parent checkout flow. | |
CheckoutPaneBase:: |
protected | property | The entity type manager. | |
CheckoutPaneBase:: |
protected | property | The current order. | |
CheckoutPaneBase:: |
public | function |
Builds a summary of the pane values. Overrides CheckoutPaneInterface:: |
3 |
CheckoutPaneBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
|
CheckoutPaneBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
7 |
CheckoutPaneBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
CheckoutPaneBase:: |
public | function |
Gets the pane display label. Overrides CheckoutPaneInterface:: |
|
CheckoutPaneBase:: |
public | function |
Gets the pane ID. Overrides CheckoutPaneInterface:: |
|
CheckoutPaneBase:: |
public | function |
Gets the pane label. Overrides CheckoutPaneInterface:: |
|
CheckoutPaneBase:: |
public | function |
Gets the pane step ID. Overrides CheckoutPaneInterface:: |
|
CheckoutPaneBase:: |
public | function |
Gets the pane weight. Overrides CheckoutPaneInterface:: |
|
CheckoutPaneBase:: |
public | function |
Gets the pane wrapper element. Overrides CheckoutPaneInterface:: |
|
CheckoutPaneBase:: |
public | function |
Determines whether the pane is visible. Overrides CheckoutPaneInterface:: |
4 |
CheckoutPaneBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
|
CheckoutPaneBase:: |
public | function |
Sets the current order. Overrides CheckoutPaneInterface:: |
|
CheckoutPaneBase:: |
public | function |
Sets the pane step ID. Overrides CheckoutPaneInterface:: |
|
CheckoutPaneBase:: |
public | function |
Sets the pane weight. Overrides CheckoutPaneInterface:: |
|
CheckoutPaneBase:: |
public | function |
Form validation handler. Overrides PluginFormInterface:: |
|
CheckoutPaneBase:: |
public | function |
Validates the pane form. Overrides CheckoutPaneInterface:: |
4 |
CheckoutPaneBase:: |
public | function |
Constructs a new CheckoutPaneBase object. Overrides PluginBase:: |
6 |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
OrderSummary:: |
public | function |
Form constructor. Overrides CheckoutPaneBase:: |
|
OrderSummary:: |
public | function |
Builds a summary of the pane configuration. Overrides CheckoutPaneBase:: |
|
OrderSummary:: |
public | function |
Builds the pane form. Overrides CheckoutPaneInterface:: |
|
OrderSummary:: |
public | function |
Gets default configuration for this plugin. Overrides CheckoutPaneBase:: |
|
OrderSummary:: |
public | function |
Form submission handler. Overrides CheckoutPaneBase:: |
|
OrderSummary:: |
public | function |
Handles the submission of an pane form. Overrides CheckoutPaneBase:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |