Fix bug: ->changed is getter only, not a setter

This commit is contained in:
Juerd Waalboer 2023-01-19 05:24:50 +01:00
parent e1aed5cbdf
commit f479060576
2 changed files with 7 additions and 6 deletions

View file

@ -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;
}

View file

@ -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;