File Coverage

lib/Dancer/Plugin/Interchange6/Routes/Checkout.pm
Criterion Covered Total %
statement 18 18 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 24 24 100.0


line stmt bran cond sub pod time code
1             package Dancer::Plugin::Interchange6::Routes::Checkout;
2              
3 2     2   8 use Dancer ':syntax';
  2         1  
  2         10  
4 2     2   531 use Dancer::Plugin;
  2         2  
  2         106  
5 2     2   8 use Dancer::Plugin::Interchange6;
  2         3  
  2         319  
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 1     1 1 1 my $routes_config = shift;
29              
30             return sub {
31 2     2   12523 my %values;
32              
33             # add stuff useful for cart display
34 2         8 my $cart = cart;
35 2         52 $values{cart_subtotal} = $cart->subtotal;
36 2         12281 $values{cart_total} = $cart->total;
37 2         239 $values{cart} = $cart->products;
38              
39             # call before_checkout_display route so template tokens
40             # can be injected
41 2         10 execute_hook('before_checkout_display', \%values);
42 2         496 template $routes_config->{checkout}->{template}, \%values;
43             }
44 1         3 }
45              
46             1;