added email receipt and "my purchases" page
This commit is contained in:
parent
93454e36f9
commit
74b3d3def6
10 changed files with 203 additions and 181 deletions
|
|
@ -8,6 +8,7 @@ use WebGUI::Asset::Template;
|
|||
use WebGUI::Exception::Shop;
|
||||
use WebGUI::Form;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Inbox;
|
||||
use WebGUI::Paginator;
|
||||
use WebGUI::Shop::Admin;
|
||||
use WebGUI::Shop::AddressBook;
|
||||
|
|
@ -354,6 +355,27 @@ sub getPaymentGateway {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getTransactionIdsForUser (session, [ userId ])
|
||||
|
||||
Returns an array reference of transactionIds for a given user ordered by date descending. Class method.
|
||||
|
||||
=head3 userId
|
||||
|
||||
The id of the user to fetch transactions for. Defaults to the current user.
|
||||
|
||||
=cut
|
||||
|
||||
sub getTransactionIdsForUser {
|
||||
my ($class, $session, $userId) = @_;
|
||||
unless (defined $userId) {
|
||||
$userId = $session->user->userId;
|
||||
}
|
||||
return $session->db->buildArrayRef("select transactionId from transaction where userId=? order by dateOfPurchase desc",[$userId]);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 new ( session, transactionId )
|
||||
|
|
@ -437,8 +459,6 @@ sub newByGatewayId {
|
|||
return $class->new( $session, $transactionId );
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 thankYou ()
|
||||
|
|
@ -745,6 +765,34 @@ STOP
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_manageMy ()
|
||||
|
||||
Makes transaction information printable.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_manageMy {
|
||||
my ($class, $session) = @_;
|
||||
my %var = ();
|
||||
my $url = $session->url;
|
||||
|
||||
# build list
|
||||
foreach my $id (@{$class->getTransactionIdsForUser($session)}) {
|
||||
my $transaction = $class->new($session, $id);
|
||||
push @{$var{transactions}}, {
|
||||
%{$transaction->get},
|
||||
viewDetailUrl => $url->page('shop=transaction;method=viewMy;transactionId='.$id),
|
||||
amount => sprintf("%.2f", $transaction->get('amount')),
|
||||
};
|
||||
}
|
||||
|
||||
# render
|
||||
my $template = WebGUI::Asset::Template->new($session, $session->setting->get("shopMyPurchasesTemplateId"));
|
||||
return $session->style->userStyle($template->process(\%var));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_print ()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue