Business-Cart-Generic
view release on metacpan or search on metacpan
lib/Business/Cart/Generic/View/Order.pm view on Meta::CPAN
package Business::Cart::Generic::View::Order;
use strict;
use warnings;
use JSON::XS;
use Moose;
use Text::Xslate 'mark_raw';
extends 'Business::Cart::Generic::View::Base';
use namespace::autoclean;
our $VERSION = '0.85';
# -----------------------------------------------
sub build_order_html
{
my($self) = @_;
$self -> db -> logger -> log(debug => 'build_order_html()');
# Use config to get some defaults.
my($config) = $self -> config;
# Use product table to get default (lowest) product id when products are ordered by name.
my(@product2id) = $self -> db -> schema -> resultset('Product') -> search({}, {columns => [qw/name id/], order_by => 'name'});
my($zone_map, $min_id) = $self -> db -> get_special_id2name_map('Zone', 'country_id', $$config{default_country_id});
my($zone_menu) = $self -> build_special_select($zone_map, $$config{default_zone_id}, 'zone_id');
# Make YUI happy by turning the HTML into 1 long line.
my($html) = $self -> templater -> render
(
'online.order.page.tx',
{ # TODO Default billing etc addresses. Default customer.
billing_address_menu => mark_raw($self -> build_select('StreetAddress', 1, 'billing_address_id', [qw/street_1 name postcode/]) ),
country_menu => mark_raw($self -> build_select('Country', $$config{default_country_id}, 'country_id', [qw/name/], "change_country(country_id.options[country_id.selectedIndex].value)") ),
customer_address_menu => mark_raw($self -> build_select('StreetAddress', 2, 'customer_address_id', [qw/street_1 name postcode/]) ),
customer_name_menu => mark_raw($self -> build_select('Customer', 1) ),
delivery_address_menu => mark_raw($self -> build_select('StreetAddress', 3, 'delivery_address_id', [qw/street_1 name postcode/]) ),
payment_method_menu => mark_raw($self -> build_select('PaymentMethod', 1, 'payment_method_id') ),
product_menu => mark_raw($self -> build_select('Product', $product2id[0] -> id, 'product_id', [qw/name description price currency_id/]) ),
sid => $self -> db -> session -> id,
tax_class_menu => mark_raw($self -> build_select('TaxClass', $$config{default_tax_class_id}, 'tax_class_id') ),
zone_menu => mark_raw($zone_menu),
}
);
$html =~ s/\n//g;
return $html;
} # End of build_order_html.
# -----------------------------------------------
sub build_head_js
{
my($self) = @_;
$self -> db -> logger -> log(debug => 'build_head_js()');
return $self -> templater -> render
(
'online.order.page.js',
{
sid => $self -> db -> session -> id,
}
);
( run in 0.802 second using v1.01-cache-2.11-cpan-99c4e6809bf )