we now have shop settings admin screen
This commit is contained in:
parent
2fc985fe54
commit
cbe9cc29df
5 changed files with 259 additions and 29 deletions
Binary file not shown.
|
|
@ -63,9 +63,13 @@ sub _formatFunction {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $function = shift;
|
my $function = shift;
|
||||||
my $url;
|
my $url;
|
||||||
if (exists $function->{func}) {
|
if ($function->{url}) {
|
||||||
|
$url = $function->{url};
|
||||||
|
}
|
||||||
|
elsif (exists $function->{func}) {
|
||||||
$url = $self->session->url->page("func=".$function->{func});
|
$url = $self->session->url->page("func=".$function->{func});
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$url = $self->session->url->page("op=".$function->{op});
|
$url = $self->session->url->page("op=".$function->{op});
|
||||||
}
|
}
|
||||||
my $i18n = WebGUI::International->new($self->session);
|
my $i18n = WebGUI::International->new($self->session);
|
||||||
|
|
@ -390,12 +394,12 @@ sub getAdminFunction {
|
||||||
},
|
},
|
||||||
"commerce" => {
|
"commerce" => {
|
||||||
title => {
|
title => {
|
||||||
id => "commerce settings",
|
id => "shop",
|
||||||
namespace => "Commerce",
|
namespace => "Shop",
|
||||||
},
|
},
|
||||||
icon => "commerce.gif",
|
icon => "commerce.gif",
|
||||||
op => "editCommerceSettings",
|
url => $self->session->url->page("shop=admin"),
|
||||||
class => 'WebGUI::Operation::Commerce',
|
group => "3",
|
||||||
},
|
},
|
||||||
"subscriptions" => {
|
"subscriptions" => {
|
||||||
title => {
|
title => {
|
||||||
|
|
@ -437,7 +441,8 @@ sub getAdminFunction {
|
||||||
return $functions if $testing;
|
return $functions if $testing;
|
||||||
if ($id) {
|
if ($id) {
|
||||||
return $self->_formatFunction($functions->{$id});
|
return $self->_formatFunction($functions->{$id});
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
my %names;
|
my %names;
|
||||||
foreach my $id (keys %{$functions}) {
|
foreach my $id (keys %{$functions}) {
|
||||||
my $func = $self->_formatFunction($functions->{$id});
|
my $func = $self->_formatFunction($functions->{$id});
|
||||||
|
|
|
||||||
|
|
@ -61,25 +61,6 @@ sub handler {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 www_cart ()
|
|
||||||
|
|
||||||
Hand off to the cart.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub www_cart {
|
|
||||||
my $session = shift;
|
|
||||||
my $output = undef;
|
|
||||||
my $method = "www_". ( $session->form->get("method") || "view");
|
|
||||||
my $cart = WebGUI::Shop::Cart->create($session);
|
|
||||||
if ($cart->can($method)) {
|
|
||||||
$output = $cart->$method();
|
|
||||||
}
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
|
|
||||||
=head2 www_address ()
|
=head2 www_address ()
|
||||||
|
|
||||||
Hand off to the address book.
|
Hand off to the address book.
|
||||||
|
|
@ -99,14 +80,40 @@ sub www_address {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 www_manageSettings ()
|
=head2 www_admin ()
|
||||||
|
|
||||||
Display the commerce settings page.
|
Hand off to admin processor.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub www_manageSettings {
|
sub www_admin {
|
||||||
my $session = shift;
|
my $session = shift;
|
||||||
|
my $output = undef;
|
||||||
|
my $method = "www_". ( $session->form->get("method") || "editSettings");
|
||||||
|
my $admin = WebGUI::Shop::Admin->new($session);
|
||||||
|
if ($admin->can($method)) {
|
||||||
|
$output = $admin->$method();
|
||||||
|
}
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 www_cart ()
|
||||||
|
|
||||||
|
Hand off to the cart.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub www_cart {
|
||||||
|
my $session = shift;
|
||||||
|
my $output = undef;
|
||||||
|
my $method = "www_". ( $session->form->get("method") || "view");
|
||||||
|
my $cart = WebGUI::Shop::Cart->create($session);
|
||||||
|
if ($cart->can($method)) {
|
||||||
|
$output = $cart->$method();
|
||||||
|
}
|
||||||
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
|
||||||
146
lib/WebGUI/Shop/Admin.pm
Normal file
146
lib/WebGUI/Shop/Admin.pm
Normal file
|
|
@ -0,0 +1,146 @@
|
||||||
|
package WebGUI::Shop::Admin;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use Class::InsideOut qw{ :std };
|
||||||
|
use WebGUI::AdminConsole;
|
||||||
|
use WebGUI::Exception::Shop;
|
||||||
|
use WebGUI::HTMLForm;
|
||||||
|
use WebGUI::International;
|
||||||
|
|
||||||
|
|
||||||
|
=head1 NAME
|
||||||
|
|
||||||
|
Package WebGUI::Shop::Admin
|
||||||
|
|
||||||
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
All the admin stuff that didn't fit elsewhere.
|
||||||
|
|
||||||
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
|
use WebGUI::Shop::Admin;
|
||||||
|
|
||||||
|
my $admin = WebGUI::Shop::Admin->new($session);
|
||||||
|
|
||||||
|
=head1 METHODS
|
||||||
|
|
||||||
|
These subroutines are available from this package:
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
public session => my %session;
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 getAdminConsole ()
|
||||||
|
|
||||||
|
Returns a reference to the admin console with all submenu items already added.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub getAdminConsole {
|
||||||
|
my $self = shift;
|
||||||
|
my $ac = WebGUI::AdminConsole->new($self->session);
|
||||||
|
my $i18n = WebGUI::International->new($self->session, "Shop");
|
||||||
|
my $url = $self->session->url;
|
||||||
|
$ac->addSubmenuItem($url->page("shop=admin"), $i18n->get("shop settings"));
|
||||||
|
$ac->addSubmenuItem($url->page("shop=tax"), $i18n->get("taxes"));
|
||||||
|
$ac->addSubmenuItem($url->page("shop=pay"), $i18n->get("payment methods"));
|
||||||
|
$ac->addSubmenuItem($url->page("shop=ship"), $i18n->get("shipping methods"));
|
||||||
|
$ac->addSubmenuItem($url->page("shop=transactions"), $i18n->get("transactions"));
|
||||||
|
return $ac;
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 new ( session )
|
||||||
|
|
||||||
|
Constructor.
|
||||||
|
|
||||||
|
=head3 session
|
||||||
|
|
||||||
|
A reference to the current session.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, $session) = @_;
|
||||||
|
unless (defined $session && $session->isa("WebGUI::Session")) {
|
||||||
|
WebGUI::Error::InvalidObject->throw(expected=>"WebGUI::Session", got=>(ref $session), error=>"Need a session.");
|
||||||
|
}
|
||||||
|
my $self = register $class;
|
||||||
|
my $id = id $self;
|
||||||
|
$session{ $id } = $session;
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 session ()
|
||||||
|
|
||||||
|
Returns a reference to the current session.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 www_editSettings ()
|
||||||
|
|
||||||
|
Displays the general commerce settings.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub www_editSettings {
|
||||||
|
my $self = shift;
|
||||||
|
return $self->session->privilege->adminOnly() unless ($self->session->user->isInGroup("3"));
|
||||||
|
my $i18n = WebGUI::International->new($self->session, "Shop");
|
||||||
|
my $ac = $self->getAdminConsole;
|
||||||
|
my $setting = $self->session->setting;
|
||||||
|
my $form = WebGUI::HTMLForm->new($self->session);
|
||||||
|
$form->hidden(name=>"shop", value=>"admin");
|
||||||
|
$form->hidden(name=>"method", value=>"editSettingsSave");
|
||||||
|
$form->template(
|
||||||
|
name => "shopCartTemplateId",
|
||||||
|
value => $setting->get("shopCartTemplateId"),
|
||||||
|
label => $i18n->get("shopping cart template"),
|
||||||
|
namespace => "Shop/Cart",
|
||||||
|
hoverHelp => $i18n->get("shopping cart template help"),
|
||||||
|
);
|
||||||
|
$form->template(
|
||||||
|
name => "shopAddressBookTemplateId",
|
||||||
|
value => $setting->get("shopAddressBookTemplateId"),
|
||||||
|
label => $i18n->get("address book template"),
|
||||||
|
namespace => "Shop/AddressBook",
|
||||||
|
hoverHelp => $i18n->get("address book template help"),
|
||||||
|
);
|
||||||
|
$form->template(
|
||||||
|
name => "shopAddressTemplateId",
|
||||||
|
value => $setting->get("shopAddressTemplateId"),
|
||||||
|
namespace => "Shop/Address",
|
||||||
|
label => $i18n->get("edit address template"),
|
||||||
|
hoverHelp => $i18n->get("edit address template help"),
|
||||||
|
);
|
||||||
|
$form->submit;
|
||||||
|
return $ac->render($form->print, $i18n->get("shop settings"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 www_editSettingsSave ()
|
||||||
|
|
||||||
|
Saves the general commerce settings.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub www_editSettingsSave {
|
||||||
|
my $self = shift;
|
||||||
|
return $self->session->privilege->adminOnly() unless ($self->session->user->isInGroup("3"));
|
||||||
|
my ($setting, $form) = $self->session->quick(qw(setting form));
|
||||||
|
$setting->set("shopCartTemplateId", $form->get("shopCartTemplateId", "template"));
|
||||||
|
$setting->set("shopAddressBookTemplateId", $form->get("shopAddressBookTemplateId", "template"));
|
||||||
|
$setting->set("shopAddressTemplateId", $form->get("shopAddressTemplateId", "template"));
|
||||||
|
return $self->www_editSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
@ -3,6 +3,72 @@ package WebGUI::i18n::English::Shop;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
our $I18N = {
|
our $I18N = {
|
||||||
|
'shopping cart template' => {
|
||||||
|
message => q|Cart Template|,
|
||||||
|
lastUpdated => 0,
|
||||||
|
context => q|commerce setting|
|
||||||
|
},
|
||||||
|
|
||||||
|
'shopping cart template help' => {
|
||||||
|
message => q|Choose the template that you want used to render the shopping cart.|,
|
||||||
|
lastUpdated => 0,
|
||||||
|
context => q|commerce setting help|
|
||||||
|
},
|
||||||
|
|
||||||
|
'address book template' => {
|
||||||
|
message => q|Address Book Template|,
|
||||||
|
lastUpdated => 0,
|
||||||
|
context => q|commerce setting|
|
||||||
|
},
|
||||||
|
|
||||||
|
'address book template help' => {
|
||||||
|
message => q|Choose the template you want used to render the address book.|,
|
||||||
|
lastUpdated => 0,
|
||||||
|
context => q|commerce setting help|
|
||||||
|
},
|
||||||
|
|
||||||
|
'edit address template' => {
|
||||||
|
message => q|Edit Address Template|,
|
||||||
|
lastUpdated => 0,
|
||||||
|
context => q|commerce setting|
|
||||||
|
},
|
||||||
|
|
||||||
|
'edit address template help' => {
|
||||||
|
message => q|Choose the template you want used to render the address edit form.|,
|
||||||
|
lastUpdated => 0,
|
||||||
|
context => q|commerce setting help|
|
||||||
|
},
|
||||||
|
|
||||||
|
'transactions' => {
|
||||||
|
message => q|Transactions|,
|
||||||
|
lastUpdated => 0,
|
||||||
|
context => q|admin function label|
|
||||||
|
},
|
||||||
|
|
||||||
|
'payment methods' => {
|
||||||
|
message => q|Payment Methods|,
|
||||||
|
lastUpdated => 0,
|
||||||
|
context => q|admin function label|
|
||||||
|
},
|
||||||
|
|
||||||
|
'shipping methods' => {
|
||||||
|
message => q|Shipping Methods|,
|
||||||
|
lastUpdated => 0,
|
||||||
|
context => q|admin function label|
|
||||||
|
},
|
||||||
|
|
||||||
|
'taxes' => {
|
||||||
|
message => q|Taxes|,
|
||||||
|
lastUpdated => 0,
|
||||||
|
context => q|admin function label|
|
||||||
|
},
|
||||||
|
|
||||||
|
'shop settings' => {
|
||||||
|
message => q|Shop Settings|,
|
||||||
|
lastUpdated => 0,
|
||||||
|
context => q|admin function label|
|
||||||
|
},
|
||||||
|
|
||||||
'is a required field' => {
|
'is a required field' => {
|
||||||
message => q|%s is a required field.|,
|
message => q|%s is a required field.|,
|
||||||
lastUpdated => 0,
|
lastUpdated => 0,
|
||||||
|
|
@ -189,6 +255,12 @@ our $I18N = {
|
||||||
context => q|a button the user clicks on to go back to shopping after viewing the cart|
|
context => q|a button the user clicks on to go back to shopping after viewing the cart|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'shop' => {
|
||||||
|
message => q|Shop|,
|
||||||
|
lastUpdated => 0,
|
||||||
|
context => q|the title of all commerce related stuff in the admin console|
|
||||||
|
},
|
||||||
|
|
||||||
'ship to button' => {
|
'ship to button' => {
|
||||||
message => q|Ship To|,
|
message => q|Ship To|,
|
||||||
lastUpdated => 0,
|
lastUpdated => 0,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue