Remove 'plus' plugin
The functionality is redundant with the 'repeat' plugin. I don't think anyone actually uses 'plus'.
This commit is contained in:
parent
e5c004958f
commit
a93b825836
1 changed files with 0 additions and 41 deletions
41
plugins/plus
41
plugins/plus
|
@ -1,41 +0,0 @@
|
|||
#!perl
|
||||
|
||||
HELP "+<N>" => "Add N more items of the previous thing";
|
||||
|
||||
my $limit = 200;
|
||||
my $err_limit = "Repetition is limited at $limit items.";
|
||||
my $err_pfand = "Plugins 'pfand' and 'repeat' cannot be combined.";
|
||||
|
||||
sub command($self, $cart, $command, @) {
|
||||
return ABORT, $err_pfand if $cart->entries('is_pfand');
|
||||
|
||||
my ($post) = $command =~ /^\+(\d+)?$/
|
||||
or return NEXT;
|
||||
|
||||
return ABORT, "Can't modify an empty transaction." if not $cart->size;
|
||||
|
||||
my $last = ($cart->entries)[-1];
|
||||
|
||||
return REJECT, "Addition only works on products." if not $last->has_attribute('product_id');
|
||||
|
||||
if ($post) {
|
||||
return REJECT, $err_limit if $last->quantity + $post > $limit;
|
||||
|
||||
$last->quantity($last->quantity + $post);
|
||||
return ACCEPT;
|
||||
}
|
||||
|
||||
return "Add to previous product", \&add;
|
||||
}
|
||||
|
||||
sub add($self, $cart, $arg, @) {
|
||||
$arg =~ /^\d+$/ and $arg > 0
|
||||
or return REJECT, "Invalid value.";
|
||||
|
||||
my $last = ($cart->entries)[-1];
|
||||
return REJECT, $err_limit if $last->quantity + $arg > $limit;
|
||||
|
||||
$last->quantity($last->quantity + $arg);
|
||||
return ACCEPT;
|
||||
}
|
||||
|
Loading…
Add table
Reference in a new issue