From f4790605769b1a7099227b6a1c85371d58d19d6c Mon Sep 17 00:00:00 2001 From: Juerd Waalboer Date: Thu, 19 Jan 2023 05:24:50 +0100 Subject: [PATCH] Fix bug: ->changed is getter only, not a setter --- lib/RevBank/Cart.pm | 8 +++++--- plugins/statiegeld_tokens | 5 ++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/RevBank/Cart.pm b/lib/RevBank/Cart.pm index 9357300..4a96cf5 100644 --- a/lib/RevBank/Cart.pm +++ b/lib/RevBank/Cart.pm @@ -118,13 +118,15 @@ sub entries($self, $attribute = undef) { return @entries; } -sub changed($self) { +sub changed($self, $keep = 0) { my $changed = 0; for my $entry ($self->entries('changed')) { - $entry->attribute('changed', undef); + $entry->attribute('changed', undef) unless $keep; $changed = 1; } - $changed = 1 if delete $self->{changed}; + $changed = 1 if $self->{changed}; + delete $self->{changed} unless $keep; + return $changed; } diff --git a/plugins/statiegeld_tokens b/plugins/statiegeld_tokens index a3d7720..6c0d7c7 100644 --- a/plugins/statiegeld_tokens +++ b/plugins/statiegeld_tokens @@ -180,9 +180,8 @@ sub hook_checkout_prepare($class, $cart, $username, $transaction_id, @) { return ABORT if %warnings_by_type and not $cart->size; - if (%warnings_by_type and $cart->changed) { # resets 'changed' attr. - print "\n"; # Between warnings and transaction overview - $cart->changed(1); # restore attribute + if (%warnings_by_type and $cart->changed(1)) { + print "\n"; # Between warnings and transaction overview } return;