Revision 223b4621
Von Werner Hahn vor mehr als 3 Jahren hinzugefügt
SL/ShopConnector/WooCommerce.pm | ||
---|---|---|
34 | 34 |
$dbh->with_transaction( sub{ |
35 | 35 |
#update status on server |
36 | 36 |
$shoporder->{status} = "processing"; |
37 |
my $answer = $self->set_orderstatus($shoporder->{id}, "fetched");
|
|
37 |
my $answer = $self->set_orderstatus($shoporder->{id}, "completed");
|
|
38 | 38 |
unless($answer){ |
39 | 39 |
push @errors,($::locale->text('Saving failed. Error message from the server: #1', $answer->message)); |
40 | 40 |
return 0; |
... | ... | |
77 | 77 |
"orders", |
78 | 78 |
undef, |
79 | 79 |
"get", |
80 |
"&per_page=$otf&status=pending"
|
|
80 |
"&per_page=$otf&status=processing&after=2020-12-31T23:59:59&order=asc"
|
|
81 | 81 |
); |
82 | 82 |
my %fetched_orders; |
83 | 83 |
if($answer->{success}) { |
84 | 84 |
my $orders = $answer->{data}; |
85 | 85 |
foreach my $shoporder(@{$orders}){ |
86 |
|
|
87 | 86 |
$dbh->with_transaction( sub{ |
88 | 87 |
#update status on server |
89 |
$shoporder->{status} = "processing";
|
|
90 |
my $anser = $self->set_orderstatus($$shoporder->{id}, "fetched");
|
|
88 |
$shoporder->{status} = "completed";
|
|
89 |
my $anwser = $self->set_orderstatus($shoporder->{id}, "completed");
|
|
91 | 90 |
unless($answer){ |
92 | 91 |
push @errors,($::locale->text('Saving failed. Error message from the server: #1', $answer->message)); |
93 | 92 |
return 0; |
... | ... | |
179 | 178 |
my $shop_id = $self->config->id; |
180 | 179 |
|
181 | 180 |
# Mapping to table shoporders. See https://woocommerce.github.io/woocommerce-rest-api-docs/?shell#order-properties |
181 |
my $d_street; |
|
182 |
if ( $import->{shipping}->{address_1} ne "" ) { |
|
183 |
$d_street = $import->{shipping}->{address_1} . ($import->{shipping}->{address_2} ? " " . $import->{shipping}->{address_2} : ""); |
|
184 |
} else { |
|
185 |
$d_street = $import->{billing}->{address_1} . ($import->{billing}->{address_2} ? " " . $import->{billing}->{address_2} : ""); |
|
186 |
} |
|
182 | 187 |
my %columns = ( |
183 | 188 |
#billing |
184 | 189 |
billing_firstname => $import->{billing}->{first_name}, |
... | ... | |
197 | 202 |
#billing_greeting => "", |
198 | 203 |
#billing_fax => "", |
199 | 204 |
#billing_vat => "", |
200 |
#billing_company => "",
|
|
205 |
billing_company => $import->{billing}->{company},
|
|
201 | 206 |
#billing_department => "", |
202 | 207 |
|
203 | 208 |
#customer |
... | ... | |
224 | 229 |
#customer_vat => "", |
225 | 230 |
|
226 | 231 |
#shipping |
227 |
delivery_firstname => $import->{shipping}->{first_name}, |
|
228 |
delivery_lastname => $import->{shipping}->{last_name}, |
|
229 |
delivery_company => $import->{shipping}->{company}, |
|
232 |
delivery_firstname => $import->{shipping}->{first_name} || $import->{billing}->{first_name},
|
|
233 |
delivery_lastname => $import->{shipping}->{last_name} || $import->{billing}->{last_name},
|
|
234 |
delivery_company => $import->{shipping}->{company} || $import->{billing}->{company},
|
|
230 | 235 |
#address_1 address_2 |
231 |
delivery_street => $import->{shipping}->{address_1} . ($import->{shipping}->{address_2} ? " " . $import->{shipping}->{address_2} : ""),
|
|
232 |
delivery_city => $import->{shipping}->{city}, |
|
236 |
delivery_street => $d_street,
|
|
237 |
delivery_city => $import->{shipping}->{city} || $import->{billing}->{city},
|
|
233 | 238 |
#state ??? |
234 |
delivery_zipcode => $import->{shipping}->{postcode}, |
|
235 |
delivery_country => $import->{shipping}->{country}, |
|
239 |
delivery_zipcode => $import->{shipping}->{postcode} || $import->{billing}->{postcode},
|
|
240 |
delivery_country => $import->{shipping}->{country} || $import->{billing}->{country},
|
|
236 | 241 |
#delivery_department => "", |
237 | 242 |
#delivery_email => "", |
238 | 243 |
#delivery_fax => "", |
... | ... | |
257 | 262 |
#discount_total |
258 | 263 |
#discount_tax |
259 | 264 |
#shipping_total |
260 |
shipping_costs => $import->{shipping_costs},
|
|
265 |
shipping_costs => $import->{shipping_total},
|
|
261 | 266 |
#shipping_tax |
262 |
shipping_costs_net => $import->{shipping_costs} - $import->{shipping_tax},
|
|
267 |
shipping_costs_net => $import->{shipping_total},
|
|
263 | 268 |
#cart_tax |
264 | 269 |
#total |
265 | 270 |
amount => $import->{total}, |
... | ... | |
597 | 602 |
|
598 | 603 |
sub set_orderstatus { |
599 | 604 |
my ($self,$order_id, $status) = @_; |
600 |
if ($status eq "fetched") { $status = "processing"; } |
|
601 |
if ($status eq "completed") { $status = "completed"; }
|
|
605 |
# if ($status eq "fetched") { $status = "processing"; }
|
|
606 |
# if ($status eq "processing") { $status = "completed"; }
|
|
602 | 607 |
my %new_status = (status => $status); |
603 | 608 |
my $status_json = SL::JSON::to_json( \%new_status); |
604 | 609 |
my $answer = $self->send_request("orders/$order_id", $status_json, "put"); |
Auch abrufbar als: Unified diff
WooCommerce: Shopübernahme Anpassung Lieferadresse und Stadi