From 8a8eb7f5433eafc886d7a570c59bb250948469f6 Mon Sep 17 00:00:00 2001
From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Date: Tue, 12 Sep 2023 11:48:32 +0000
Subject: [PATCH] Bug 34355: Add a plugin hook - before_orderline_create

Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
---
 Koha/MarcOrder.pm | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/Koha/MarcOrder.pm b/Koha/MarcOrder.pm
index be8f9073196..8faa0492df1 100644
--- a/Koha/MarcOrder.pm
+++ b/Koha/MarcOrder.pm
@@ -60,6 +60,7 @@ use Koha::Import::Records;
 use Koha::Acquisition::Currencies;
 use Koha::Acquisition::Booksellers;
 use Koha::Acquisition::Baskets;
+use Koha::Plugins;
 
 =head1 NAME
 
@@ -1105,6 +1106,14 @@ sub create_items_and_generate_order_hash {
 
                 # Remove uncertainprice flag if we have found a price in the MARC record
                 $orderinfo{uncertainprice} = 0 if $orderinfo{listprice};
+                Koha::Plugins->call(
+                    'before_orderline_create',
+                    {
+                        marcrecord => $fields->{marcrecord},
+                        orderline  => \%orderinfo,
+                        marcfields => $fields
+                    }
+                );
 
                 my $order = Koha::Acquisition::Order->new( \%orderinfo );
                 $order->populate_with_prices_for_ordering();
@@ -1152,6 +1161,14 @@ sub create_items_and_generate_order_hash {
 
         # Remove uncertainprice flag if we have found a price in the MARC record
         $orderinfo{uncertainprice} = 0 if $orderinfo{listprice};
+        Koha::Plugins->call(
+            'before_orderline_create',
+            {
+                marcrecord => $fields->{marcrecord},
+                orderline  => \%orderinfo,
+                marcfields => $fields
+            }
+        );
 
         my $order = Koha::Acquisition::Order->new( \%orderinfo );
         $order->populate_with_prices_for_ordering();
-- 
2.39.3 (Apple Git-146)