From 47c101753a580a2dbd33fa60fa81ff0c14cc093b Mon Sep 17 00:00:00 2001 From: Morven Lewis-Everley Date: Mon, 28 Oct 2024 15:28:01 +0000 Subject: [PATCH] Allow linking of a related object to customisations and price modifiers --- src/Model/LineItemCustomisation.php | 3 ++- src/Model/PriceModifier.php | 12 +++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Model/LineItemCustomisation.php b/src/Model/LineItemCustomisation.php index 1e59312..22ec288 100644 --- a/src/Model/LineItemCustomisation.php +++ b/src/Model/LineItemCustomisation.php @@ -48,7 +48,8 @@ class LineItemCustomisation extends DataObject implements TaxableProvider * @var array */ private static $has_one = [ - "Parent" => LineItem::class + "Parent" => LineItem::class, + 'RelatedObject' => DataObject::class ]; /** diff --git a/src/Model/PriceModifier.php b/src/Model/PriceModifier.php index eb0a703..954ffd1 100644 --- a/src/Model/PriceModifier.php +++ b/src/Model/PriceModifier.php @@ -25,24 +25,26 @@ class PriceModifier extends DataObject private static $table_name = 'Orders_PriceModifier'; private static $db = [ - 'Name' => 'Varchar', - 'ModifyPrice' => 'Decimal(9,3)' + 'Name' => 'Varchar', + 'ModifyPrice' => 'Decimal(9,3)' ]; private static $has_one = [ - 'LineItem' => LineItem::class, + 'LineItem' => LineItem::class, + 'RelatedObject' => DataObject::class, 'Customisation' => LineItemCustomisation::class ]; private static $summary_fields = [ 'Name', 'ModifyPrice', - 'CustomisationID' + 'RelatedObject.Title' ]; private static $field_labels = [ 'Name' => 'Modification applied', - 'ModifyPrice' => 'Modify base item price' + 'ModifyPrice' => 'Modify base item price', + 'RelatedObject.Title' => 'Base Object' ]; public function isNegative(): bool