very close to having ship driver management working
This commit is contained in:
parent
fc3ccba4f3
commit
e4d76f0b3b
5 changed files with 45 additions and 15 deletions
|
|
@ -50,16 +50,15 @@ A list of properties to assign to this PayDriver. See C<definition> for details
|
||||||
|
|
||||||
sub addPaymentGateway {
|
sub addPaymentGateway {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $session = shift;
|
|
||||||
my $requestedClass = shift;
|
my $requestedClass = shift;
|
||||||
|
my $options = shift;
|
||||||
WebGUI::Error::InvalidParam->throw(error => q{Must provide a class to create an object})
|
WebGUI::Error::InvalidParam->throw(error => q{Must provide a class to create an object})
|
||||||
unless defined $requestedClass;
|
unless defined $requestedClass;
|
||||||
WebGUI::Error::InvalidParam->throw(error => q{The requested class is not enabled in your WebGUI configuration file}, param => $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) } );
|
unless isIn($requestedClass, (keys %{$self->getDrivers}) );
|
||||||
my $options = shift;
|
|
||||||
WebGUI::Error::InvalidParam->throw(error => q{You must pass a hashref of options to create a new PayDriver object})
|
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 };
|
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;
|
return $driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,16 +50,15 @@ A list of properties to assign to this ShipperDriver. See C<definition> for det
|
||||||
|
|
||||||
sub addShipper {
|
sub addShipper {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $session = shift;
|
|
||||||
my $requestedClass = shift;
|
my $requestedClass = shift;
|
||||||
|
my $options = shift;
|
||||||
WebGUI::Error::InvalidParam->throw(error => q{Must provide a class to create an object})
|
WebGUI::Error::InvalidParam->throw(error => q{Must provide a class to create an object})
|
||||||
unless defined $requestedClass;
|
unless defined $requestedClass;
|
||||||
WebGUI::Error::InvalidParam->throw(error => q{The requested class is not enabled in your WebGUI configuration file}, param => $requestedClass)
|
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($session) } );
|
unless isIn($requestedClass, (keys %{$self->getDrivers}) );
|
||||||
my $options = shift;
|
|
||||||
WebGUI::Error::InvalidParam->throw(error => q{You must pass a hashref of options to create a new ShipDriver object})
|
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 };
|
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;
|
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 ( )
|
=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.
|
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 ($self) = @_;
|
||||||
my $form = $self->session->form;
|
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 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 $driver = $self->getShipper($form->get("driver"));
|
||||||
my $output = undef;
|
my $output = undef;
|
||||||
my $method = "www_". ( $form->get("do"));
|
my $method = "www_". ( $form->get("do"));
|
||||||
|
|
|
||||||
|
|
@ -150,8 +150,8 @@ sub definition {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
my %properties = (
|
my %properties = (
|
||||||
name => 'Shipper Driver',
|
name => 'Shipper Driver',
|
||||||
fields => \%fields,
|
properties => \%fields,
|
||||||
);
|
);
|
||||||
push @{ $definition }, \%properties;
|
push @{ $definition }, \%properties;
|
||||||
return $definition;
|
return $definition;
|
||||||
|
|
@ -221,7 +221,7 @@ sub getEditForm {
|
||||||
name => 'className',
|
name => 'className',
|
||||||
value => $self->className,
|
value => $self->className,
|
||||||
);
|
);
|
||||||
$form->dynamicForm($definition, 'fields', $self);
|
$form->dynamicForm($definition, 'properties', $self);
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -333,4 +333,21 @@ a GUID.
|
||||||
|
|
||||||
=cut
|
=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;
|
1;
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,8 @@ sub definition {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
my %properties = (
|
my %properties = (
|
||||||
name => 'Flat Rate',
|
name => 'Flat Rate',
|
||||||
fields => \%fields,
|
properties => \%fields,
|
||||||
);
|
);
|
||||||
push @{ $definition }, \%properties;
|
push @{ $definition }, \%properties;
|
||||||
return $class->SUPER::definition($session, $definition);
|
return $class->SUPER::definition($session, $definition);
|
||||||
|
|
|
||||||
|
|
@ -230,7 +230,7 @@ sub getEditForm {
|
||||||
$form->hidden(name=>"activityId", value=>$self->getId);
|
$form->hidden(name=>"activityId", value=>$self->getId);
|
||||||
$form->hidden(name=>"className", value=>$self->get("className"));
|
$form->hidden(name=>"className", value=>$self->get("className"));
|
||||||
my $fullDefinition = $self->definition($self->session);
|
my $fullDefinition = $self->definition($self->session);
|
||||||
$form->dynamicForm($fullDefinition, $self);
|
$form->dynamicForm($fullDefinition, "properties", $self);
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue