Revision f71e1c67
Von Tamino vor fast 4 Jahren hinzugefügt
SL/IS.pm | ||
---|---|---|
1441 | 1441 |
} |
1442 | 1442 |
} |
1443 | 1443 |
|
1444 |
# update shop status |
|
1445 |
my $invoice = SL::DB::Invoice->new( id => $form->{id} )->load; |
|
1446 |
my @linked_shop_orders = $invoice->linked_records( |
|
1447 |
from => 'ShopOrder', |
|
1448 |
via => ['Order', 'DeliveryOrder'], |
|
1449 |
); |
|
1450 |
if (scalar @linked_shop_orders == 1){ |
|
1451 |
#do update |
|
1452 |
my $shop_order = $linked_shop_orders[0][0]; |
|
1453 |
require SL::Shop; |
|
1454 |
my $shop_config = SL::DB::Manager::Shop->get_first( query => [ id => $shop_order->shop_id ] ); |
|
1455 |
my $shop = SL::Shop->new( config => $shop_config ); |
|
1456 |
$shop->connector->set_orderstatus($shop_order->shop_trans_id, "completed"); |
|
1457 |
} |
|
1458 |
|
|
1444 | 1459 |
return 1; |
1445 | 1460 |
} |
1446 | 1461 |
|
SL/ShopConnector/Base.pm | ||
---|---|---|
15 | 15 |
|
16 | 16 |
sub get_article { die 'get_article needs to be implemented' } |
17 | 17 |
|
18 |
sub get_categories { die 'get_order needs to be implemented' }
|
|
18 |
sub get_categories { die 'get_categories needs to be implemented' }
|
|
19 | 19 |
|
20 |
sub get_version { die 'get_order needs to be implemented' } |
|
20 |
sub get_version { die 'get_version needs to be implemented' } |
|
21 |
|
|
22 |
sub set_orderstatus { die 'set_orderstatus needs to be implemented' } |
|
21 | 23 |
|
22 | 24 |
1; |
23 | 25 |
|
... | ... | |
50 | 52 |
|
51 | 53 |
=item C<get_version> |
52 | 54 |
|
55 |
=item C<set_orderstatus> |
|
56 |
|
|
53 | 57 |
=back |
54 | 58 |
|
55 | 59 |
=head1 SEE ALSO |
SL/ShopConnector/Shopware.pm | ||
---|---|---|
46 | 46 |
}; |
47 | 47 |
|
48 | 48 |
if(!@errors){ |
49 |
$self->set_orderstatus($import->{data}->{id}, "fetched"); |
|
49 | 50 |
$of++; |
50 | 51 |
}else{ |
51 | 52 |
flash_later('error', $::locale->text('Database errors: #1', @errors)); |
... | ... | |
100 | 101 |
}; |
101 | 102 |
|
102 | 103 |
if(!@errors){ |
104 |
$self->set_orderstatus($shoporder->{id}, "fetched"); |
|
103 | 105 |
$of++; |
104 | 106 |
}else{ |
105 | 107 |
flash_later('error', $::locale->text('Database errors: #1', @errors)); |
... | ... | |
401 | 403 |
return SL::JSON::decode_json($data_json); |
402 | 404 |
} |
403 | 405 |
|
406 |
sub set_orderstatus { |
|
407 |
my ($self,$order_id, $status) = @_; |
|
408 |
if ($status eq "fetched") { $status = 1; } |
|
409 |
if ($status eq "completed") { $status = 2; } |
|
410 |
my %new_status = (orderStatusId => $status); |
|
411 |
my $new_status_json = SL::JSON::to_json(\%new_status); |
|
412 |
$self->connector->put($self->url . "api/orders/$order_id", Content => $new_status_json); |
|
413 |
} |
|
414 |
|
|
404 | 415 |
sub init_url { |
405 | 416 |
my ($self) = @_; |
406 | 417 |
$self->url($self->config->protocol . "://" . $self->config->server . ":" . $self->config->port . $self->config->path); |
Auch abrufbar als: Unified diff
ShopConnector: set OrderStatus in Shop