Skip to content
Snippets Groups Projects
Commit 33898316 authored by Jonathan Sacksick's avatar Jonathan Sacksick Committed by Jonathan Sacksick
Browse files

Issue #3119159 by jsacksick, skyredwang: commerce_order_item_table needs to...

Issue #3119159 by jsacksick, skyredwang: commerce_order_item_table needs to filter out orphan order items.
parent 512ee55a
No related branches found
No related tags found
No related merge requests found
......@@ -219,3 +219,17 @@ function commerce_order_post_update_13() {
return $message;
}
/**
* Revert the 'commerce_order_item_table' view to hide orphaned order items.
*/
function commerce_order_post_update_14() {
/** @var \Drupal\commerce\Config\ConfigUpdaterInterface $config_updater */
$config_updater = \Drupal::service('commerce.config_updater');
$result = $config_updater->revert([
'views.view.commerce_order_item_table',
]);
$message = implode('<br>', $result->getFailed());
return $message;
}
......@@ -384,14 +384,14 @@ display:
plugin_id: text_custom
relationships: { }
arguments:
order_id:
id: order_id
order_item_id:
id: order_item_id
table: commerce_order_item
field: order_id
field: order_item_id
relationship: none
group_type: group
admin_label: ''
default_action: 'not found'
default_action: empty
exception:
value: all
title_enable: false
......@@ -416,10 +416,10 @@ display:
type: none
fail: 'not found'
validate_options: { }
break_phrase: false
break_phrase: true
not: false
entity_type: commerce_order_item
entity_field: order_id
entity_field: order_item_id
plugin_id: numeric
display_extenders: { }
cache_metadata:
......
......@@ -26,11 +26,12 @@ class OrderItemTable extends FormatterBase {
/** @var \Drupal\commerce_order\Entity\OrderInterface $order */
$order = $items->getEntity();
$elements = [];
$order_item_ids = array_column($order->get('order_items')->getValue(), 'target_id');
$elements[0] = [
'#type' => 'view',
// @todo Allow the view to be configurable.
'#name' => 'commerce_order_item_table',
'#arguments' => [$order->id()],
'#arguments' => $order_item_ids ? [implode('+', $order_item_ids)] : NULL,
'#embed' => TRUE,
];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment