Skip to content
Snippets Groups Projects
Commit a595f266 authored by Michael Lutz's avatar Michael Lutz Committed by Bojan Živanović
Browse files

Issue #2860853 by mikeNCM, bojanz: Save custom data from proposed shipments...

Issue #2860853 by mikeNCM, bojanz: Save custom data from proposed shipments into ->data of shipments if shipment doesn't have a matching field
parent d9939dba
No related branches found
No related tags found
No related merge requests found
......@@ -68,6 +68,9 @@ class Shipment extends ContentEntityBase implements ShipmentInterface {
if ($this->hasField($field_name)) {
$this->set($field_name, $value);
}
else {
$this->setData($field_name, $value);
}
}
// @todo Reset the shipping method/service/amount if the items changed.
}
......
......@@ -252,6 +252,7 @@ class ShipmentTest extends CommerceKernelTestBase {
// State is not a custom field, but it simplifies this test.
'custom_fields' => [
'state' => 'ready',
'no_field' => 'custom_value',
],
]);
$shipment = Shipment::create([
......@@ -265,6 +266,7 @@ class ShipmentTest extends CommerceKernelTestBase {
$this->assertEquals($proposed_shipment->getItems(), $shipment->getItems());
$this->assertEquals($proposed_shipment->getPackageTypeId(), $shipment->getPackageType()->getId());
$this->assertEquals('ready', $shipment->getState()->value);
$this->assertEquals('custom_value', $shipment->getData('no_field'));
}
/**
......
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