<%args> $c => 'default' <%init> use Data::Dumper; #my @bob = ( {'item_name' => 'Diana', # 'item_quantity' => '1', # 'item_image_path' => 'images/lrg-diana-sm.jpg', # 'item_price' => '125'}, # # {'item_name' => 'Isus', # 'item_quantity' => '2', # 'item_image_path' => 'images/lrg-isis-sm.jpg', # 'item_price' => '150'}); my @bob; #my $response = $m->comp('parse_response'); #$m->session->{cart_array} = \@bob; <& $c &> <%def default> <%doc>
<%doc>
ChaliceArt Receipt
Please print this page. This is your official receipt.

<& list_cart_contents&>







<%def display_billing_info> <%init> my $response = $m->comp('get_response'); #use Data::Dumper; #print "
";
#print Dumper($response);
#$m->flush_buffer;
#$m->abort;

 
 
 
Customer Billing Information
 
First Name: 
<%$response->{'x_first_name'}%>
Last Name: 
<%$response->{'x_last_name'}%>
Address: 
<%$response->{'x_address'}%>
City: 
<%$response->{'x_city'}%>
State: 
<%$response->{'x_state'}%>
Zip Code: 
<%$response->{'x_zip'}%>
Phone: 
<%$response->{'x_phone'}%>
E-Mail: 
<%$response->{'x_email'}%>
 
   
Customer Shipping Information
 
First Name: 
%if($response->{'x_ship_to_first_name'}){ <%$response->{'x_ship_to_first_name'}%> %}else{ <%$response->{'x_first_name'}%> %}
Last Name: 
%if($response->{'x_ship_to_last_name'}){ <%$response->{'x_ship_to_last_name'}%> %}else{ <%$response->{'x_last_name'}%> %}
Address: 
%if($response->{'x_ship_to_address'}){ <%$response->{'x_ship_to_address'}%> %}else{ <%$response->{'x_address'}%> %}
City: 
%if($response->{'x_ship_to_city'}){ <%$response->{'x_ship_to_city'}%> %}else{ <%$response->{'x_city'}%> %}
State: 
%if($response->{'x_ship_to_state'}){ <%$response->{'x_ship_to_state'}%> %}else{ <%$response->{'x_state'}%> %}
Zip: 
%if($response->{'x_ship_to_zip'}){ <%$response->{'x_ship_to_zip'}%> %}else{ <%$response->{'x_zip'}%> %}
  <%def get_response> <%init> use DBI; my $x_invoice_num = $m->session->{'x_invoice_num'}; my $dbh;# = DBI->connect('DBI:mysql:CCS_Shopping_Carts', 'ccscart', 'cwebcomm'); #$dbh->disconnect; my $Table = 'Transactions'; $dbh = DBI->connect('DBI:mysql:chaliceart', 'chaliceart', 'chaliceart'); my $response = $dbh->selectrow_hashref("select * from Transactions where x_invoice_num=?",undef,$x_invoice_num); $dbh->disconnect; return $response; <%def get_admin_email> <%init> use DBI; my $dbh = DBI->connect('DBI:mysql:chaliceart', 'chaliceart', 'chaliceart'); return $dbh->selectrow_array("select reciept_email from cart_config where cart_config_id = ?",undef,'1'); <%def list_cart_contents> <%init> my $response = $m->comp('get_response'); $m->comp('send_emails', 'response' => $response); my $list = $m->session->{cart_array}; my $subtotal = 0; my $shipping = $response->{'x_freight'}; my $total = 0; % foreach my $item (@$list) { % $subtotal += ($item->{item_price} * $item->{item_quantity}); %# $shipping += ($item->{item_quantity} * $item->{item_shipping}); %} <&'display_billing_info'&>
Image
Item
Quantity
Price
<%$item->{item_title}%>
<%$item->{item_name}%>
<%$item->{item_extra}%>
<%$item->{item_quantity}%>
$<%sprintf("%.2f",$item->{item_price} * $item->{item_quantity})%>
 
Description
%if($response->{'x_tax'}){ %}else{ %}
Subtotal
$<%sprintf("%.2f",$subtotal)%>
Applicable Taxes
$<%sprintf("%.2f",$response->{'x_tax'})%>
Shipping
$<%sprintf("%.2f",$shipping)%>
Total
$<%sprintf("%.2f",$subtotal + $shipping + $response->{'x_tax'})%>
Shipping
$<%sprintf("%.2f",$shipping)%>
Total
$<%sprintf("%.2f",$subtotal + $shipping)%>
Shipping Method
<%$list->[0]->{item_shippping_method}%>
<%perl> $m->comp('clear_cart'); <%def send_emails> <%init> use MIME::Lite; my $response = $ARGS{'response'}; my $list = $m->session->{cart_array}; my $subtotal = 0; my $shipping = $response->{'x_freight'}; my $total = 0; my $body_header = " Chalice Art Order Confirmation "; my $body = ''; my $auth_net = "Authorize.net Information Invoice Number: ".$response->{'x_invoice_num'}." Transaction Id: ".$response->{'x_trans_id'}." Credit Card Number(last 5 digits): ".$response->{'x_card_num'}." "; $body .= "Order Information "; foreach my $item (@$list) { $subtotal += ($item->{item_price} * $item->{item_quantity}); #$shipping += ($item->{item_quantity} * $item->{item_shipping}); $body .= " Item Title: ".$item->{item_title}." "; $body .= " Item Name: ".$item->{item_name}." "; $body .= " Item Extra: ".$item->{item_extra}." "; $body .= " Item Quantity: ".$item->{item_quantity}." "; $body .= " Item Subtotal: ".'$'.sprintf("%.2f",$subtotal)." "; } $body .= " Shipping: ".'$'.sprintf("%.2f",$shipping)." "; if($response->{'x_tax'}){ $body .= " Applicable Taxes: ".'$'.sprintf("%.2f",$response->{'x_tax'})." "; }else{ $body .= " Applicable Taxes: \$0.00 "; } $body .= " Total: ".'$'.sprintf("%.2f",$response->{'x_amount'})." "; $body .= " Shipping Method: ".$list->[0]->{item_shippping_method}." "; $body .= "Customer Billing Information "; $body .= " First Name: ".$response->{'x_first_name'}." "; $body .= " Last Name: ".$response->{'x_last_name'}." "; $body .= " Address: ".$response->{'x_address'}." "; $body .= " City: ".$response->{'x_city'}." "; $body .= " State: ".$response->{'x_state'}." "; $body .= " Zip: ".$response->{'x_zip'}." "; $body .= " Phone: ".$response->{'x_phone'}." "; $body .= " Email: ".$response->{'x_email'}." "; $body .= "Customer Shipping Information "; if($response->{'x_ship_to_first_name'}){ $body .= " First Name: ".$response->{'x_ship_to_first_name'}." "; }else{ $body .= " First Name: ".$response->{'x_first_name'}." "; } if($response->{'x_ship_to_last_name'}){ $body .= " Last Name: ".$response->{'x_ship_to_last_name'}." "; }else{ $body .= " Last Name: ".$response->{'x_last_name'}." "; } if($response->{'x_ship_to_address'}){ $body .= " Address: ".$response->{'x_ship_to_address'}." "; }else{ $body .= " Address: ".$response->{'x_address'}." "; } if($response->{'x_ship_to_city'}){ $body .= " City: ".$response->{'x_ship_to_city'}." "; }else{ $body .= " City: ".$response->{'x_city'}." "; } if($response->{'x_ship_to_state'}){ $body .= " State: ".$response->{'x_ship_to_state'}." "; }else{ $body .= " State: ".$response->{'x_state'}." "; } if($response->{'x_ship_to_zip'}){ $body .= " Zip: ".$response->{'x_ship_to_zip'}." "; }else{ $body .= " Zip: ".$response->{'x_zip'}." "; } my $admin_email = $m->comp('get_admin_email'); my $Chalice_email = MIME::Lite->new( To => $admin_email, Subject => 'Chalice Art Order Confirmation', From => 'Order_Confirmation@chaliceart.com', Type => 'TEXT', Data => $body_header.$auth_net.$body); $Chalice_email->send; my $Customer_email = MIME::Lite->new( To => $response->{'x_email'}, Subject => 'Chalice Art Order Conformation', From => 'Order_Conformation@chaliceart.com', Type => 'TEXT', Data => $body_header.$body); #$email->delete("date"); $Customer_email->send; #use Data::Dumper; #print "
";
#print Dumper($body,$response,$m->session);
#$m->flush_buffer;
#$m->abort;



<%def add_to_cart>
<%init>
my $current_cart = $m->session->{cart_array};

my $item_name = $m->request_args->{name};
my $item_extra = $m->request_args->{extra};
my $item_title = $m->request_args->{item_name};

#
# Check to see if we already have this item.  If so, then increment its quantity.

foreach (@$current_cart) {
 if ( ( $_->{item_name} eq $item_name ) 
&&    ($_->{item_extra} eq $item_extra) 
&&    ($_->{item_title} eq $item_title) ) {
   $_->{item_quantity} += 1;
   $m->redirect("cart.htm");
  }
}

#
# Add to cart
push(@$current_cart,
{   'item_title' => $m->request_args->{item_name},
    'item_name' => $m->request_args->{name},
    'item_extra' => $m->request_args->{extra},
    'item_quantity' => 1,
    'item_image_path' => $m->request_args->{image_path},
    'item_price' => $m->request_args->{price},
    'item_shipping' => $m->request_args->{shipping} } );

$m->session->{cart_array} = $current_cart;
$m->redirect("cart.htm");



<%def clear_cart>
<%init>
my @bob;
delete $m->session->{cart_array};
delete $m->session->{'x_invoice_num'};
#$m->redirect("http://www.chaliceart.com");