statiegeld: increase quantity instead of adding more of the same
This commit is contained in:
parent
a93b825836
commit
a555c1ddf1
1 changed files with 12 additions and 0 deletions
|
@ -66,6 +66,18 @@ sub command ($invocant, $cart, $command, @) {
|
|||
? "$addon->{description}"
|
||||
: "$addon->{description} ($product->{description})";
|
||||
|
||||
my @existing = grep {
|
||||
$_->attribute('plugin') eq $invocant->id and
|
||||
$_->attribute('addon_id') eq $addon->{id} and
|
||||
$_->{description} eq $d
|
||||
} $cart->entries('plugin');
|
||||
|
||||
if (@existing) {
|
||||
$existing[0]->quantity($existing[0]->quantity + 1);
|
||||
$cart->select($existing[0]);
|
||||
next;
|
||||
}
|
||||
|
||||
$cart
|
||||
->add(+$addon->{price}, $d, { plugin => $invocant->id, addon_id => $addon->{id} })
|
||||
->add_contra($addon->{contra}, -$addon->{price}, "$d for \$you");
|
||||
|
|
Loading…
Add table
Reference in a new issue