projects
/
kivitendo-erp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
53f7b40
)
ShopConnector: WooCommerce set OrderStatus added
author
Tamino
<tamino.steinert@web.de>
Wed, 30 Dec 2020 11:22:06 +0000
(12:22 +0100)
committer
Werner Hahn
<wh@futureworldsearch.net>
Thu, 24 Jun 2021 14:45:12 +0000
(16:45 +0200)
SL/ShopConnector/WooCommerce.pm
patch
|
blob
|
history
diff --git
a/SL/ShopConnector/WooCommerce.pm
b/SL/ShopConnector/WooCommerce.pm
index
9a3f8ea
..
f65570d
100644
(file)
--- a/
SL/ShopConnector/WooCommerce.pm
+++ b/
SL/ShopConnector/WooCommerce.pm
@@
-32,18
+32,16
@@
sub get_one_order {
my $shoporder = $answer->{data};
$dbh->with_transaction( sub{
my $shoporder = $answer->{data};
$dbh->with_transaction( sub{
- unless ($self->import_data_to_shop_order($shoporder)) { return 0;}
-
#update status on server
$shoporder->{status} = "processing";
#update status on server
$shoporder->{status} = "processing";
- my %new_status = ( status => "processing" );
- my $status_json = SL::JSON::to_json( \%new_status);
- $answer = $self->send_request("orders/$shoporder->{id}", $status_json, "put");
- unless($answer->{success}){
+ my $anser = $self->set_orderstatus($$shoporder->{id}, "fetched");
+ unless($answer){
push @errors,($::locale->text('Saving failed. Error message from the server: #1', $answer->message));
push @errors,($::locale->text('Saving failed. Error message from the server: #1', $answer->message));
- return 0
+ return 0
;
}
}
+ unless ($self->import_data_to_shop_order($shoporder)) { return 0;}
+
1;
})or do {
push @errors,($::locale->text('Saving failed. Error message from the database: #1', $dbh->error));
1;
})or do {
push @errors,($::locale->text('Saving failed. Error message from the database: #1', $dbh->error));
@@
-87,18
+85,16
@@
sub get_new_orders {
foreach my $shoporder(@{$orders}){
$dbh->with_transaction( sub{
foreach my $shoporder(@{$orders}){
$dbh->with_transaction( sub{
- unless ($self->import_data_to_shop_order($shoporder)) { return 0;}
-
#update status on server
$shoporder->{status} = "processing";
#update status on server
$shoporder->{status} = "processing";
- my %new_status = ( status => "processing" );
- my $status_json = SL::JSON::to_json( \%new_status);
- $answer = $self->send_request("orders/$shoporder->{id}", $status_json, "put");
- unless($answer->{success}){
+ my $anser = $self->set_orderstatus($$shoporder->{id}, "fetched");
+ unless($answer){
push @errors,($::locale->text('Saving failed. Error message from the server: #1', $answer->message));
return 0;
}
push @errors,($::locale->text('Saving failed. Error message from the server: #1', $answer->message));
return 0;
}
+ unless ($self->import_data_to_shop_order($shoporder)) { return 0;}
+
1;
})or do {
push @errors,($::locale->text('Saving failed. Error message from the database: #1', $dbh->error));
1;
})or do {
push @errors,($::locale->text('Saving failed. Error message from the database: #1', $dbh->error));
@@
-446,6
+442,19
@@
sub get_version {
}
}
}
}
+sub set_orderstatus {
+ my ($self,$order_id, $status) = @_;
+ if ($status eq "fetched") { $status = "processing"; }
+ if ($status eq "completed") { $status = "completed"; }
+ my %new_status = (status => $status);
+ my $status_json = SL::JSON::to_json( \%new_status);
+ my $answer = $self->send_request("orders/$order_id", $status_json, "put");
+ unless($answer->{success}){
+ return 0;
+ }
+ return 1;
+}
+
sub create_url {
my ($self) = @_;
my $request = $_[1];
sub create_url {
my ($self) = @_;
my $request = $_[1];