my ($data, $tr) = @_;
$tr->fclass($_)->replace_content($data->{$_}) for qw/title subtitle stock/;
$tr->fclass('price')->replace_content(stringify_money $data->{price});
+ $tr->fclass('freepost')->detach unless $data->{freepost};
$tr->fclass('title')->attr('data-product', $data->{product});
$tr->fclass('title')->attr('href', '/details/'.$data->{product}.'/'.make_slug $data->{title});
# $tr->fclass('title')->attr('data-summary', $data->{summary});
sub continue_table_row {
my ($data, $tr) = @_;
$tr->fclass($_)->replace_content($data->{$_}) for qw/title subtitle quantity/;
+ $tr->fclass('freepost')->detach unless $data->{freepost};
$tr->fclass('price')->replace_content(stringify_money $data->{subtotal});
$tr->fclass('title')->attr('data-product', $data->{product});
}
my $req = Plack::Request->new($env);
my $params = $req->body_parameters;
- my ($quant, $total, @data, @notes);
+ my ($quant, $quant_freepost, $total, @data, @notes) = (0) x 3;
for (sort keys %$params) {
next unless /^quant/;
next unless $params->{$_};
}
$data->{subtotal} = $data->{price} * $data->{quantity};
$quant += $data->{quantity};
+ $quant_freepost += $data->{quantity} if $data->{freepost};
$total += $data->{subtotal};
push @data, $data
}
}
$tree->look_down(name => 'discount')->detach unless $dvalue;
$tree->fid('discount_tr')->detach unless $dvalue;
- my $postage = 220 + 50 * $quant;
+ my $postage = 220 + 50 * ($quant - $quant_freepost);
+ $postage = 0 if $quant == $quant_freepost;
$tree->fid('postage')->replace_content(stringify_money $postage);
$total += $postage;
$tree->fid('total')->replace_content(stringify_money $total);