Skip to content

Commit

Permalink
Fix bug: ->changed is getter only, not a setter
Browse files Browse the repository at this point in the history
  • Loading branch information
Juerd committed Jan 19, 2023
1 parent e1aed5c commit f479060
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 5 additions & 3 deletions lib/RevBank/Cart.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 2 additions & 3 deletions plugins/statiegeld_tokens
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f479060

Please sign in to comment.