Interchange6/Routes/Checkout.pm untested

filter: Statementstmt 0.0% 0 / 19 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 24 CC 1 SCAR 6.9
CC
1
Cov
0%
checkout_route
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Dancer::Plugin::Interchange6::Routes::Checkout;
2  
3 use Dancer ':syntax';
4 use Dancer::Plugin;
5 use Dancer::Plugin::Interchange6;
6  
7 =head1 NAME
8  
9 Dancer::Plugin::Interchange6::Routes::Checkout - Checkout routes for Interchange6 Shop Machine
10  
11 =cut
12  
13 register_hook 'before_checkout_display';
14  
15 =head1 DESCRIPTION
16  
17 This route isn't active by default and B<not recommended>.
18  
19 =head1 FUNCTIONS
20  
21 =head2 checkout_route
22  
23 Returns the checkout route based on the passed routes configuration.
24  
25 =cut
26  
27 sub checkout_route {
28 my $routes_config = shift;
29  
30 return sub {
31 my %values;
32  
33 # add stuff useful for cart display
34 my $cart = cart;
35 $values{cart_subtotal} = $cart->subtotal;
36 $values{cart_total} = $cart->total;
37 $values{cart} = $cart->products;
38  
39 # call before_checkout_display route so template tokens
40 # can be injected
41 execute_hook('before_checkout_display', \%values);
42 template $routes_config->{checkout}->{template}, \%values;
43 }
44 }
45  
46 1;