Commit a595f266 authored by mikelutz's avatar mikelutz Committed by bojanz

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
......@@ -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'));
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment