diff --git a/lib/WebGUI/Shop/Pay.pm b/lib/WebGUI/Shop/Pay.pm index 795e5bbdc..cae4a66b3 100644 --- a/lib/WebGUI/Shop/Pay.pm +++ b/lib/WebGUI/Shop/Pay.pm @@ -50,16 +50,15 @@ A list of properties to assign to this PayDriver. See C for details sub addPaymentGateway { my $self = shift; - my $session = shift; my $requestedClass = shift; + my $options = shift; WebGUI::Error::InvalidParam->throw(error => q{Must provide a class to create an object}) unless defined $requestedClass; WebGUI::Error::InvalidParam->throw(error => q{The requested class is not enabled in your WebGUI configuration file}, param => $requestedClass) - unless isIn($requestedClass, keys %{$self->getDrivers($session) } ); - my $options = shift; + unless isIn($requestedClass, (keys %{$self->getDrivers}) ); WebGUI::Error::InvalidParam->throw(error => q{You must pass a hashref of options to create a new PayDriver object}) unless defined($options) and ref $options eq 'HASH' and scalar keys %{ $options }; - my $driver = eval { WebGUI::Pluggable::instanciate($requestedClass, 'create', [ $session, $options ]) }; + my $driver = eval { WebGUI::Pluggable::instanciate($requestedClass, 'create', [ $self->session, $options ]) }; return $driver; } diff --git a/lib/WebGUI/Shop/Ship.pm b/lib/WebGUI/Shop/Ship.pm index 92acbe8a0..e3bc80841 100644 --- a/lib/WebGUI/Shop/Ship.pm +++ b/lib/WebGUI/Shop/Ship.pm @@ -50,16 +50,15 @@ A list of properties to assign to this ShipperDriver. See C for det sub addShipper { my $self = shift; - my $session = shift; my $requestedClass = shift; + my $options = shift; WebGUI::Error::InvalidParam->throw(error => q{Must provide a class to create an object}) unless defined $requestedClass; - WebGUI::Error::InvalidParam->throw(error => q{The requested class is not enabled in your WebGUI configuration file}, param => $requestedClass) - unless isIn($requestedClass, keys %{$self->getDrivers($session) } ); - my $options = shift; + WebGUI::Error::InvalidParam->throw(error => qq{The requested class $requestedClass is not enabled in your WebGUI configuration file}, param => $requestedClass) + unless isIn($requestedClass, (keys %{$self->getDrivers}) ); WebGUI::Error::InvalidParam->throw(error => q{You must pass a hashref of options to create a new ShipDriver object}) unless defined($options) and ref $options eq 'HASH' and scalar keys %{ $options }; - my $driver = eval { WebGUI::Pluggable::instanciate($requestedClass, 'create', [ $session, $options ]) }; + my $driver = eval { WebGUI::Pluggable::instanciate($requestedClass, 'create', [ $self->session, $options ]) }; return $driver; } @@ -189,6 +188,20 @@ Returns a reference to the current session. #------------------------------------------------------------------- +=head2 www_addDriver () + +=cut + +sub www_addDriver { + my $self = shift; + my $form = $self->session->form; + WebGUI::Error::InvalidParam->throw(error => q{must have a form var called className with a driver class name }) if ($form->get("className") eq ""); + my $shipper = $self->addShipper($form->get("className"), { $form->get("className")->getName($self->session), enabled=>0}); + return $shipper->www_edit; +} + +#------------------------------------------------------------------- + =head2 www_do ( ) Let's ship drivers do method calls. Requires a driver param in the post form vars which contains the id of the driver to load. @@ -199,6 +212,7 @@ sub www_do { my ($self) = @_; my $form = $self->session->form; WebGUI::Error::InvalidParam->throw(error => q{must have a form var called driver with a driver id }) if ($form->get("driver") eq ""); + WebGUI::Error::InvalidParam->throw(error => q{must have a form var called do with a method name in the driver }) if ($form->get("do") eq ""); my $driver = $self->getShipper($form->get("driver")); my $output = undef; my $method = "www_". ( $form->get("do")); diff --git a/lib/WebGUI/Shop/ShipDriver.pm b/lib/WebGUI/Shop/ShipDriver.pm index 3684cbd41..134359dcf 100644 --- a/lib/WebGUI/Shop/ShipDriver.pm +++ b/lib/WebGUI/Shop/ShipDriver.pm @@ -150,8 +150,8 @@ sub definition { }, ); my %properties = ( - name => 'Shipper Driver', - fields => \%fields, + name => 'Shipper Driver', + properties => \%fields, ); push @{ $definition }, \%properties; return $definition; @@ -221,7 +221,7 @@ sub getEditForm { name => 'className', value => $self->className, ); - $form->dynamicForm($definition, 'fields', $self); + $form->dynamicForm($definition, 'properties', $self); return $form; } @@ -333,4 +333,21 @@ a GUID. =cut +#------------------------------------------------------------------- + +=head2 www_edit ( ) + +Generates an edito form. + +=cut + +sub www_edit { + my $self = shift; + my $admin = WebGUI::Shop::Admin->new($self->session); + my $i18n = WebGUI::International->new($self->session, "Shop"); + return $admin->getAdminConsole->render($self->getEditForm->print, $i18n->get("shipping methods")); +} + + + 1; diff --git a/lib/WebGUI/Shop/ShipDriver/FlatRate.pm b/lib/WebGUI/Shop/ShipDriver/FlatRate.pm index 8e692e0bf..9d89c0a68 100644 --- a/lib/WebGUI/Shop/ShipDriver/FlatRate.pm +++ b/lib/WebGUI/Shop/ShipDriver/FlatRate.pm @@ -91,8 +91,8 @@ sub definition { }, ); my %properties = ( - name => 'Flat Rate', - fields => \%fields, + name => 'Flat Rate', + properties => \%fields, ); push @{ $definition }, \%properties; return $class->SUPER::definition($session, $definition); diff --git a/lib/WebGUI/Workflow/Activity.pm b/lib/WebGUI/Workflow/Activity.pm index 73b7a83b3..0aaa0bd97 100644 --- a/lib/WebGUI/Workflow/Activity.pm +++ b/lib/WebGUI/Workflow/Activity.pm @@ -230,7 +230,7 @@ sub getEditForm { $form->hidden(name=>"activityId", value=>$self->getId); $form->hidden(name=>"className", value=>$self->get("className")); my $fullDefinition = $self->definition($self->session); - $form->dynamicForm($fullDefinition, $self); + $form->dynamicForm($fullDefinition, "properties", $self); return $form; }