-
Notifications
You must be signed in to change notification settings - Fork 2
/
commerce_shipping.module
79 lines (67 loc) · 2.27 KB
/
commerce_shipping.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
* @file
* Contains commerce_shipping.module..
*/
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
/**
* Implements hook_help().
*/
function commerce_shipping_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the commerce_shipping module.
case 'help.page.commerce_shipping':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Handles shipping and fulfilment for Drupal Commerce') . '</p>';
return $output;
default:
}
}
/**
* Adds the default shipment items field to the shipment.
*
* Shipment items can't be a base field because the Views integration is broken.
* Instead, it is created as a configurable field for the shipment.
*
*/
function commerce_shipping_add_shipment_item_field() {
//Evan you can probably use this for refernce to some stuff you might need to add for this
/*$view_display = commerce_get_entity_display('commerce_order', $shipment->id(), 'view');
$view_display->setComponent('line_items', [
'type' => 'commerce_line_item_table',
'weight' => 0,
]);
$view_display->save();
$form_display = commerce_get_entity_display('commerce_order', $shipment->id(), 'form');
$form_display->setComponent('line_items', [
'type' => 'inline_entity_form_complex',
'weight' => 0,
'settings' => [
'override_labels' => TRUE,
'label_singular' => 'line item',
'label_plural' => 'line items',
],
]);
$form_display->save();*/
}
/**
* Implements hook_entity_base_field_info().
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* @return mixed
*/
function commerce_shipping_entity_base_field_info(EntityTypeInterface $entity_type) {
if ($entity_type->id() === 'commerce_order') {
$fields['shipment'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Shipment'))
->setDescription(t('The shipment.'))
->setRequired(TRUE)
->setSetting('target_type', 'commerce_shipment');
return $fields;
}
// \Drupal::entityDefinitionUpdateManager()->applyUpdates();
}