fix
This commit is contained in:
parent
4499c3c19d
commit
22d30f3f47
1 changed files with 9 additions and 0 deletions
|
|
@ -108,10 +108,13 @@ sub priceLineItem {
|
||||||
my $quantity = shift;
|
my $quantity = shift;
|
||||||
# this is the output of ShoppingCart->getItems (the \@normal arrayref).
|
# this is the output of ShoppingCart->getItems (the \@normal arrayref).
|
||||||
my $cartItems = shift;
|
my $cartItems = shift;
|
||||||
|
use Data::Dumper;
|
||||||
|
# $self->session->errorHandler->warn('normal contents: '.Dumper($cartItems));
|
||||||
# this is the default price of this event.
|
# this is the default price of this event.
|
||||||
my $price = $self->{_event}->{price};
|
my $price = $self->{_event}->{price};
|
||||||
# get the list of discount passes that this event is "under"
|
# get the list of discount passes that this event is "under"
|
||||||
my @discountPasses = split(/::/,$self->{_event}->{passId});
|
my @discountPasses = split(/::/,$self->{_event}->{passId});
|
||||||
|
# $self->session->errorHandler->warn('discount passes: '.Dumper(\@discountPasses));
|
||||||
# return the default behavior if this event does not have a pass assigned.
|
# return the default behavior if this event does not have a pass assigned.
|
||||||
return ($price * $quantity) unless (scalar(@discountPasses) && ($self->{_event}->{passType} eq 'member'));
|
return ($price * $quantity) unless (scalar(@discountPasses) && ($self->{_event}->{passType} eq 'member'));
|
||||||
# keep a running total of this line item.
|
# keep a running total of this line item.
|
||||||
|
|
@ -122,15 +125,18 @@ sub priceLineItem {
|
||||||
foreach my $passId (@discountPasses) {
|
foreach my $passId (@discountPasses) {
|
||||||
# get a list of events that define this pass
|
# get a list of events that define this pass
|
||||||
my @passEvents = $self->session->db->buildArray("select productId from EventManagementSystem_products where passType='defines' and passId=?",[$passId]);
|
my @passEvents = $self->session->db->buildArray("select productId from EventManagementSystem_products where passType='defines' and passId=?",[$passId]);
|
||||||
|
$self->session->errorHandler->warn('pass events: '.Dumper(\@passEvents));
|
||||||
my $numberOfPasses = 0;
|
my $numberOfPasses = 0;
|
||||||
# find out if we have any of this pass's events in our cart.
|
# find out if we have any of this pass's events in our cart.
|
||||||
foreach my $item (@$cartItems) {
|
foreach my $item (@$cartItems) {
|
||||||
|
# $self->session->errorHandler->warn('quantity of this pass event: '.$item->{quantity});
|
||||||
$numberOfPasses += $item->{quantity} if (
|
$numberOfPasses += $item->{quantity} if (
|
||||||
$item->{item}->type eq 'Event'
|
$item->{item}->type eq 'Event'
|
||||||
&& isIn($item->{item}->{_event}->{productId},@passEvents)
|
&& isIn($item->{item}->{_event}->{productId},@passEvents)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if ($numberOfPasses) {
|
if ($numberOfPasses) {
|
||||||
|
# $self->session->errorHandler->warn('adding a discount pass.');
|
||||||
$passesInCart{$passId} = $numberOfPasses;
|
$passesInCart{$passId} = $numberOfPasses;
|
||||||
$totalPassesInCart += $numberOfPasses;
|
$totalPassesInCart += $numberOfPasses;
|
||||||
}
|
}
|
||||||
|
|
@ -141,6 +147,7 @@ sub priceLineItem {
|
||||||
my $numberOfThisPass = $passesInCart{$passId};
|
my $numberOfThisPass = $passesInCart{$passId};
|
||||||
# calculate discount.
|
# calculate discount.
|
||||||
if ($pass->{type} eq 'newPrice') {
|
if ($pass->{type} eq 'newPrice') {
|
||||||
|
$self->session->errorHandler->warn('discounted price: '.$pass->{amount});
|
||||||
$discountedPrice = (0 + $pass->{amount}) if ($price > (0 + $pass->{amount}));
|
$discountedPrice = (0 + $pass->{amount}) if ($price > (0 + $pass->{amount}));
|
||||||
} elsif ($pass->{type} eq 'amountOff') {
|
} elsif ($pass->{type} eq 'amountOff') {
|
||||||
# not yet implemented!
|
# not yet implemented!
|
||||||
|
|
@ -149,7 +156,9 @@ sub priceLineItem {
|
||||||
}
|
}
|
||||||
# while we still have passes and items left to discount.
|
# while we still have passes and items left to discount.
|
||||||
while ($numberOfThisPass && $quantity) {
|
while ($numberOfThisPass && $quantity) {
|
||||||
|
# $self->session->errorHandler->warn('applying a discount pass.');
|
||||||
$totalPrice += $discountedPrice;
|
$totalPrice += $discountedPrice;
|
||||||
|
$self->session->errorHandler->warn('new discounted price: '.$discountedPrice);
|
||||||
$quantity--;
|
$quantity--;
|
||||||
$numberOfThisPass--;
|
$numberOfThisPass--;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue