From a93b825836753eb129b9fbcf692e8e4d167d863b Mon Sep 17 00:00:00 2001 From: Juerd Waalboer Date: Mon, 30 Jan 2023 04:46:08 +0100 Subject: [PATCH] Remove 'plus' plugin The functionality is redundant with the 'repeat' plugin. I don't think anyone actually uses 'plus'. --- plugins/plus | 41 ----------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 plugins/plus diff --git a/plugins/plus b/plugins/plus deleted file mode 100644 index 6d43f46..0000000 --- a/plugins/plus +++ /dev/null @@ -1,41 +0,0 @@ -#!perl - -HELP "+" => "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; -} -