From 22d30f3f477e6b004cf79ae8141c2f319321f266 Mon Sep 17 00:00:00 2001 From: Matthew Wilson Date: Tue, 9 May 2006 15:38:01 +0000 Subject: [PATCH] fix --- lib/WebGUI/Commerce/Item/Event.pm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/WebGUI/Commerce/Item/Event.pm b/lib/WebGUI/Commerce/Item/Event.pm index 703929c54..5fe275cd0 100644 --- a/lib/WebGUI/Commerce/Item/Event.pm +++ b/lib/WebGUI/Commerce/Item/Event.pm @@ -108,10 +108,13 @@ 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. @@ -122,15 +125,18 @@ 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; } @@ -141,6 +147,7 @@ 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! @@ -149,7 +156,9 @@ 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--; }