Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 196da0e7

Von Tamino vor fast 3 Jahren hinzugefügt

  • ID 196da0e775a9bf7b33e87c2027d7993f4cbc9f34
  • Vorgänger 53f7b408
  • Nachfolger 2f5ea2de

ShopConnector: WooCommerce set OrderStatus added

Unterschiede anzeigen:

SL/ShopConnector/WooCommerce.pm
32 32
    my $shoporder = $answer->{data};
33 33

  
34 34
    $dbh->with_transaction( sub{
35
        unless ($self->import_data_to_shop_order($shoporder)) { return 0;}
36

  
37 35
        #update status on server
38 36
        $shoporder->{status} = "processing";
39
        my %new_status = ( status => "processing" );
40
        my $status_json = SL::JSON::to_json( \%new_status);
41
        $answer = $self->send_request("orders/$shoporder->{id}", $status_json, "put");
42
        unless($answer->{success}){
37
        my $anser = $self->set_orderstatus($$shoporder->{id}, "fetched");
38
        unless($answer){
43 39
          push @errors,($::locale->text('Saving failed. Error message from the server: #1', $answer->message));
44
          return 0
40
          return 0;
45 41
        }
46 42

  
43
        unless ($self->import_data_to_shop_order($shoporder)) { return 0;}
44

  
47 45
        1;
48 46
      })or do {
49 47
      push @errors,($::locale->text('Saving failed. Error message from the database: #1', $dbh->error));
......
87 85
    foreach my $shoporder(@{$orders}){
88 86

  
89 87
      $dbh->with_transaction( sub{
90
          unless ($self->import_data_to_shop_order($shoporder)) { return 0;}
91

  
92 88
          #update status on server
93 89
          $shoporder->{status} = "processing";
94
          my %new_status = ( status => "processing" );
95
          my $status_json = SL::JSON::to_json( \%new_status);
96
          $answer = $self->send_request("orders/$shoporder->{id}", $status_json, "put");
97
          unless($answer->{success}){
90
          my $anser = $self->set_orderstatus($$shoporder->{id}, "fetched");
91
          unless($answer){
98 92
            push @errors,($::locale->text('Saving failed. Error message from the server: #1', $answer->message));
99 93
            return 0;
100 94
          }
101 95

  
96
          unless ($self->import_data_to_shop_order($shoporder)) { return 0;}
97

  
102 98
          1;
103 99
      })or do {
104 100
        push @errors,($::locale->text('Saving failed. Error message from the database: #1', $dbh->error));
......
446 442
  }
447 443
}
448 444

  
445
sub set_orderstatus {
446
  my ($self,$order_id, $status) = @_;
447
  if ($status eq "fetched") { $status =  "processing"; }
448
  if ($status eq "completed") { $status = "completed"; }
449
  my %new_status = (status => $status);
450
  my $status_json = SL::JSON::to_json( \%new_status);
451
  my $answer = $self->send_request("orders/$order_id", $status_json, "put");
452
  unless($answer->{success}){
453
    return 0;
454
  }
455
  return 1;
456
}
457

  
449 458
sub create_url {
450 459
  my ($self) = @_;
451 460
  my $request = $_[1];

Auch abrufbar als: Unified diff