Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions modules/order/commerce_order.links.task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ entity.commerce_order.collection:
base_route: entity.commerce_order.collection
title: 'Orders'

entity.commerce_order.canonical:
route_name: 'entity.commerce_order.canonical'
base_route: 'entity.commerce_order.canonical'
title: 'View'

entity.commerce_order.edit_form:
route_name: 'entity.commerce_order.edit_form'
base_route: 'entity.commerce_order.edit_form'
base_route: 'entity.commerce_order.canonical'
title: 'Edit'

entity.commerce_order_type.edit_form:
Expand All @@ -17,9 +22,3 @@ entity.commerce_order_item_type.edit_form:
route_name: entity.commerce_order_item_type.edit_form
base_route: entity.commerce_order_item_type.edit_form
title: 'Edit'

entity.commerce_order.canonical:
route_name: 'entity.commerce_order.canonical'
base_route: 'entity.commerce_order.edit_form'
title: 'View'

9 changes: 9 additions & 0 deletions modules/order/commerce_order.module
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ function commerce_order_theme($existing, $type, $theme, $path) {
'commerce_order' => [
'render element' => 'elements',
],
'commerce_order__admin' => [
'base hook' => 'commerce_order',
'render element' => 'elements',
],
'commerce_order__user' => [
'base hook' => 'commerce_order',
'render element' => 'elements',
Expand Down Expand Up @@ -80,6 +84,11 @@ function template_preprocess_commerce_order(&$variables) {
foreach (Element::children($variables['elements']) as $key) {
$variables['order'][$key] = $variables['elements'][$key];
}

if ($order->getBillingProfile()) {
$profile_view_bulder = \Drupal::entityTypeManager()->getViewBuilder('profile');
$variables['order']['billing_information'] = $profile_view_bulder->view($order->getBillingProfile());
}
}

/**
Expand Down
33 changes: 33 additions & 0 deletions modules/order/commerce_order.post_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,36 @@ function commerce_order_post_update_2() {
}
}
}

/**
* Revert the Order and Profile entity view displays.
*/
function commerce_order_post_update_3() {
/** @var \Drupal\commerce\Config\ConfigUpdaterInterface $config_updater */
$config_updater = \Drupal::service('commerce.config_updater');

$views = [
'core.entity_view_display.commerce_order.default.default',
'core.entity_view_display.commerce_order.default.user',
'core.entity_view_display.profile.customer.default',
];
$result = $config_updater->revert($views, FALSE);

$success_results = $result->getSucceeded();
$failure_results = $result->getFailed();
if ($success_results) {
$message = t('Succeeded:') . '<br>';
foreach ($success_results as $success_message) {
$message .= $success_message . '<br>';
}
$message .= '<br>';
}
if ($failure_results) {
$message .= t('Failed:') . '<br>';
foreach ($failure_results as $failure_message) {
$message .= $failure_message . '<br>';
}
}

return $message;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,82 @@ dependencies:
- commerce_order.commerce_order_type.default
- field.field.commerce_order.default.order_items
module:
- commerce_order
- commerce_price
- state_machine
- user
id: commerce_order.default.default
targetEntityType: commerce_order
bundle: default
mode: default
content:
changed:
type: timestamp
weight: 4
label: inline
settings:
date_format: short
custom_date_format: ''
timezone: ''
third_party_settings: { }
completed:
label: inline
type: timestamp
weight: 2
settings:
date_format: short
custom_date_format: ''
timezone: ''
third_party_settings: { }
ip_address:
label: inline
type: string
weight: 7
settings:
link_to_entity: false
third_party_settings: { }
mail:
label: inline
type: basic_string
weight: 6
settings: { }
third_party_settings: { }
order_items:
type: entity_reference_entity_view
type: commerce_order_item_table
weight: 0
settings: { }
third_party_settings: { }
label: hidden
placed:
label: inline
type: timestamp
weight: 3
settings:
view_mode: default
link: false
date_format: short
custom_date_format: ''
timezone: ''
third_party_settings: { }
state:
label: hidden
type: state_transition_form
weight: 8
settings: { }
third_party_settings: { }
total_price:
type: commerce_price_default
weight: 1
settings:
strip_trailing_zeroes: false
display_currency_code: false
third_party_settings: { }
label: above
label: inline
uid:
label: inline
type: author
weight: 5
settings: { }
third_party_settings: { }
hidden:
billing_profile: true
order_number: true
store_id: true
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,43 @@ dependencies:
- field.field.commerce_order.default.order_items
module:
- commerce_order
- commerce_price
- entity_reference_revisions
- options
id: commerce_order.default.user
targetEntityType: commerce_order
bundle: default
mode: user
content:
billing_profile:
type: entity_reference_entity_view
weight: 3
type: entity_reference_revisions_entity_view
weight: 0
label: above
settings:
view_mode: default
link: false
link: ''
third_party_settings: { }
order_items:
type: commerce_order_item_table
weight: 4
settings: { }
completed:
label: inline
type: timestamp
weight: 2
settings:
date_format: short
custom_date_format: ''
timezone: ''
third_party_settings: { }
label: hidden
mail:
label: inline
type: basic_string
weight: 2
weight: 1
settings: { }
third_party_settings: { }
order_items:
type: commerce_order_item_table
weight: 5
settings: { }
third_party_settings: { }
label: hidden
order_number:
type: string
weight: 0
Expand All @@ -42,21 +54,28 @@ content:
placed:
label: inline
type: timestamp
weight: 1
weight: 3
settings:
date_format: medium
date_format: short
custom_date_format: ''
timezone: ''
third_party_settings: { }
store_id:
type: entity_reference_label
weight: 0
state:
type: list_default
weight: 4
label: inline
settings: { }
third_party_settings: { }
total_price:
type: commerce_price_default
weight: 6
label: above
settings:
link: false
strip_trailing_zeroes: false
display_currency_code: false
third_party_settings: { }
hidden:
changed: true
ip_address: true
total_price: true
state: true
store_id: true
uid: true
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ content:
address:
type: address_default
weight: 0
label: above
label: hidden
settings: { }
third_party_settings: { }
hidden: { }
9 changes: 5 additions & 4 deletions modules/order/src/Entity/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* "delete" = "Drupal\Core\Entity\ContentEntityDeleteForm"
* },
* "route_provider" = {
* "default" = "Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider",
* "default" = "Drupal\commerce_order\OrderRouteProvider",
* "delete-multiple" = "Drupal\entity\Routing\DeleteMultipleRouteProvider",
* },
* },
Expand Down Expand Up @@ -545,8 +545,8 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
->setDisplayConfigurable('view', TRUE);

$fields['uid'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Owner'))
->setDescription(t('The order owner.'))
->setLabel(t('Customer'))
->setDescription(t('The customer.'))
->setSetting('target_type', 'user')
->setSetting('handler', 'default')
->setDefaultValueCallback('Drupal\commerce_order\Entity\Order::getCurrentUserId')
Expand Down Expand Up @@ -646,7 +646,8 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {

$fields['changed'] = BaseFieldDefinition::create('changed')
->setLabel(t('Changed'))
->setDescription(t('The time when the order was last edited.'));
->setDescription(t('The time when the order was last edited.'))
->setDisplayConfigurable('view', TRUE);

$fields['placed'] = BaseFieldDefinition::create('timestamp')
->setLabel(t('Placed'))
Expand Down
23 changes: 23 additions & 0 deletions modules/order/src/OrderRouteProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Drupal\commerce_order;

use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;

/**
* Provides routes for the Order entity.
*/
class OrderRouteProvider extends AdminHtmlRouteProvider {

/**
* {@inheritdoc}
*/
protected function getCanonicalRoute(EntityTypeInterface $entity_type) {
$route = parent::getCanonicalRoute($entity_type);
// Replace the 'full' view mode with the 'admin' view mode.
$route->setDefault('_entity_view', 'commerce_order.admin');

return $route;
}
}
Loading