Bugfix: 'stock' counted 1 after using 'repeat'
The 'stock' plugin uses the 'product_id' field in the cart item, but this was not copied by the 'repeat' plugin. The confusion is caused by a mismatch between the API for RevBank::Cart->add and the internal representation.
This commit is contained in:
parent
3ce1874d3a
commit
b31b95ca37
2 changed files with 8 additions and 3 deletions
|
@ -15,6 +15,10 @@ sub new {
|
||||||
|
|
||||||
sub add {
|
sub add {
|
||||||
my ($self, $user, $amount, $description, $data) = @_;
|
my ($self, $user, $amount, $description, $data) = @_;
|
||||||
|
|
||||||
|
# Note: 'repeat' plugin is currently dependent on this specific
|
||||||
|
# implementation!
|
||||||
|
|
||||||
$data ||= {};
|
$data ||= {};
|
||||||
my $item = {
|
my $item = {
|
||||||
%$data, # Internal stuff, not logged or printed.
|
%$data, # Internal stuff, not logged or printed.
|
||||||
|
|
|
@ -12,10 +12,11 @@ my $err_limit = "Repetition is limited at $limit items.";
|
||||||
sub _do_repeat {
|
sub _do_repeat {
|
||||||
my ($cart, $item, $num) = @_;
|
my ($cart, $item, $num) = @_;
|
||||||
|
|
||||||
my $data = $item->{data};
|
$item->{_repeated} = 1;
|
||||||
$data->{_repeated} = 1;
|
|
||||||
|
|
||||||
$cart->add( @{ $item }{qw/user amount description/}, $data ) for 2..$num;
|
# Strongly dependent on the implementation of RevBank::Cart and the 'add'
|
||||||
|
# method. Bad idea, but meh.
|
||||||
|
$cart->add( @{ $item }{qw/user amount description/}, $item ) for 2..$num;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub command {
|
sub command {
|
||||||
|
|
Loading…
Add table
Reference in a new issue