use utf8;
use parent qw/Plack::Component/;
-our $VERSION = '0.000_007';
+our $VERSION = '0.000_008';
use DBIx::Simple;
use Email::Sender::Simple 'sendmail';
##################################################
my %db;
-my ($form, $continue, $order, $details, $pay, $display);
+my ($form, $continue, $order, $details, $pay, $display, $down);
{
sub parse_html {
$details = parse_html 'details';
$pay = parse_html 'pay';
$display = parse_html 'display';
+ $down = parse_html 'down';
}
sub stringify_money { sprintf "£%.2f", $_[0] / 100 }
header => [
From => $ENV{OOF_EMAIL_FROM},
To => $ENV{OOF_EMAIL_TO},
- Subject => "Order $id placed",
+ Subject => "Order $id placed for ".stringify_money($parms{total}),
],
body => 'A new order was placed.',
)) if $ENV{OOF_EMAIL_TO};
$tree->fid('pictures')->find('li')->iter3(\@pics, \&details_list_element);
$tree->fid('jsonld')->replace_content(encode_json product_to_schemaorg '', %data);
+ $tree->fid('dd_stock')->replace_content($data{stock});
+ $tree->fid('dd_price')->replace_content(stringify_money $data{price});
+ for (qw/brand model/) {
+ if ($data{$_}) {
+ $tree->fid("dd_$_")->replace_content($data{$_});
+ } else {
+ $tree->fid("dt_$_")->detach;
+ $tree->fid("dd_$_")->detach;
+ }
+ }
+
for my $ahref ($tree->find('a')) {
$ahref->attr(href => "/form?highlight=$id") if $ahref->attr('href') eq '/';
}
$res;
}
};
+ enable sub {
+ my $app = shift;
+ sub {
+ if (-f 'down.html') {
+ my $down_lit = HTML::Element::Library::super_literal read_file 'down.html';
+ my $tree = $down->clone;
+ $tree->fid('content')->replace_content($down_lit);
+ return [503, ['Content-type' => 'text/html; charset=utf-8'], [$tree->as_HTML]]
+ }
+ $app->(@_)
+ }
+ };
mount '/' => sub { [301, [Location => '/form'], []] };
mount '/form' => \&form_app;
mount '/continue' => \&continue_app;