If $borrowernumber is not set, there is no userenv.
So let's pick the library code set in the userenv instead of fetching
the Koha::Patron->branchcode from DB
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
if ( C4::Context->preference("AllowPurchaseSuggestionBranchChoice") ) {
my $branchcode = $input->param('branchcode') || q{};
- if ( !$branchcode && $borrowernumber ) {
- my $patron = Koha::Patrons->find($borrowernumber);
- $branchcode = $patron->branchcode;
- }
-
- if ( !$branchcode
+ if ( !$branchcode
&& C4::Context->userenv
&& C4::Context->userenv->{branch} )
{