fixed bug in database; argh. removing debug.

This commit is contained in:
Matthew Wilson 2006-05-09 15:35:10 +00:00
parent 2b49692623
commit 153858ca76

View file

@ -108,13 +108,10 @@ sub priceLineItem {
my $quantity = shift;
# this is the output of ShoppingCart->getItems (the \@normal arrayref).
my $cartItems = shift;
use Data::Dumper;
# $self->session->errorHandler->warn('normal contents: '.Dumper($cartItems));
# this is the default price of this event.
my $price = $self->{_event}->{price};
# get the list of discount passes that this event is "under"
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 ($price * $quantity) unless (scalar(@discountPasses) && ($self->{_event}->{passType} eq 'member'));
# keep a running total of this line item.
@ -125,18 +122,15 @@ sub priceLineItem {
foreach my $passId (@discountPasses) {
# 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]);
$self->session->errorHandler->warn('pass events: '.Dumper(\@passEvents));
my $numberOfPasses = 0;
# find out if we have any of this pass's events in our cart.
foreach my $item (@$cartItems) {
# $self->session->errorHandler->warn('quantity of this pass event: '.$item->{quantity});
$numberOfPasses += $item->{quantity} if (
$item->{item}->type eq 'Event'
&& isIn($item->{item}->{_event}->{productId},@passEvents)
);
}
if ($numberOfPasses) {
# $self->session->errorHandler->warn('adding a discount pass.');
$passesInCart{$passId} = $numberOfPasses;
$totalPassesInCart += $numberOfPasses;
}
@ -147,7 +141,6 @@ sub priceLineItem {
my $numberOfThisPass = $passesInCart{$passId};
# calculate discount.
if ($pass->{type} eq 'newPrice') {
$self->session->errorHandler->warn('discounted price: '.$pass->{amount});
$discountedPrice = (0 + $pass->{amount}) if ($price > (0 + $pass->{amount}));
} elsif ($pass->{type} eq 'amountOff') {
# not yet implemented!
@ -156,9 +149,7 @@ sub priceLineItem {
}
# while we still have passes and items left to discount.
while ($numberOfThisPass && $quantity) {
# $self->session->errorHandler->warn('applying a discount pass.');
$totalPrice += $discountedPrice;
$self->session->errorHandler->warn('new discounted price: '.$discountedPrice);
$quantity--;
$numberOfThisPass--;
}