Bestellung per Admin-API anlegen

Info:
Shopware 6.3.5.3

Ich bin auf der Suche welche Informationen benötigt werden, um eine Bestellung per Admin-API einzupflegen.

Mit folgenden POST gibt es zwar keine Fehlermeldung aber im Backend werden dann überhaupt keine Bestellungen mehr angezeigt.
{ „orderNumber“: „BEKG10050000“,
„paymentMethodId“: „61d02313786240309acadf49e0f2386f“,
„shippingMethodId“: „abffcb44509449a3937d219a83e49871“,
„billingAddressId“: „4c6137e199254f84b93312bf75aa437d“,
„currencyId“: „b7d2554b0ce847cd82f3ac9bd1c0dfca“,
„languageId“: „2fbb5fe2e29a4d70aa5854ce7ce3e20b“,
„salesChannelId“: „f108b892baf048ac8216180f3f94ab6d“,
„stateId“: „ffc917f348d44a60b5573a96cc1f78e0“,
„currencyFactor“: 1.0,
„orderCustomer“: {
„customerId“: „b9b21a2a321e4f8fa4c2f49025920320“,
„salutationId“: „cfd3401e736249ada8dd305e1fe41684“,
„email“: „alice.apple@example.com“,
„firstName“: „Alice“,
„lastName“: „Apple“
},
„orderDateTime“: „2021-06-04 13:00:49.460“,
„orderLineItem“: {
„productId“: „f475b2c06bf1456c82a07e5f12969bfd“,
„quantity“: 1,
„price“: {
„unitPrice“: 122.95,
„quantity“: 1,
„totalPrice“: 122.95,
„calculatedTaxes“: [
{
„tax“: 19.63,
„taxRate“: 19.0,
„price“: 122.95,
„extensions“:
}
],
„taxRules“: [
{
„taxRate“: 19.0,
„percentage“: 100.0,
„extensions“:
}
],
„referencePrice“: null,
„listPrice“: null,
„extensions“:
}
},
„price“: {
„netPrice“: 101.25,
„totalPrice“: 120.49,
„calculatedTaxes“: [
{
„tax“: 19.24,
„taxRate“: 19.0,
„price“: 120.49,
„extensions“:
}
],
„taxRules“: [
{
„taxRate“: 19.0,
„percentage“: 100.0,
„extensions“:
}
],
„positionPrice“: 120.49,
„taxStatus“: „gross“,
„extensions“:
},
„shippingCosts“: {
„unitPrice“: 0,
„quantity“: 1,
„totalPrice“: 0,
„calculatedTaxes“: [
{
„tax“: 0,
„taxRate“: 7,
„price“: 0
}
],
„taxRules“: [
{
„taxRate“: 7,
„percentage“: 100
}
],
„referencePrice“: null,
„listPrice“: null
}
}

Beim Auslesen dieser Bestellung (per API) fehlen unter „includes“ das lineItem.

Ich hoffe mir kann jemand weiter helfen.

PS:

  • Zur Zeit können wir nicht auf eine aktuellere Version wechseln.
  • Die Store-API ist keine Alternative, da wir für registrierte Kunde Bestellungen aufnehmen wollen

Hallo,

bin gerade bei demselben Problem dabei, jedoch konnte ich es lösen…

Dir fehlen hier eindeutig die Transactions, d.h. du musst den Zahlungsstatus mitschicken. (solltest in der Konsole einen Fehler finden mit „technicalName“, das deutet eben daraufhin, dass kein Zahlungsstatus mitgeschickt wird. Der Bestellstatus selbst wird über die stateId definiert.

Das Orderarray sollte folgendermaßen aussehen:

"id" => $orderId,
                            "orderNumber" => $entry[0]["number"],
                            "price" => [
                                "netPrice" => (float)$entry[0]["invoiceAmountNet"],
                                "totalPrice" => (float)$entry[0]["invoiceAmount"],
                                "rawTotal" => (float)$entry[0]["invoiceAmount"],
                                "positionPrice" => (float)$entry[0]["invoiceAmount"],
                                "taxStatus" => "gross",
                                "taxRules" => [
                                    [
                                        "taxRate" => $entry[0]["taxRate"],
                                        "percentage" => 100
                                    ]
                                ],
                                "calculatedTaxes" => [
                                    [
                                        "tax" => $entry[0]["taxRate"],
                                        "taxRate" => $entry[0]["taxRate"],
                                        "price" => (float)$entry[0]["invoiceAmount"] - (float)$entry[0]["invoiceAmountNet"]
                                    ]
                                ],
                            ],
                            "shippingCosts" => [
                                "unitPrice" => (float)$entry[0]["invoiceShipping"],
                                "totalPrice" => (float)$entry[0]["invoiceShipping"],
                                "quantity" => 1,
                                "taxRules" => [
                                    [
                                        "taxRate" => $entry[0]["taxRate"],
                                        "percentage" => 100
                                    ]
                                ],
                                "calculatedTaxes" => [
                                    [
                                        "tax" => $entry[0]["taxRate"],
                                        "taxRate" => $entry[0]["taxRate"],
                                        "price" => (float)$entry[0]["invoiceShipping"] - (float)$entry[0]["invoiceShippingNet"]
                                    ]
                                ],
                            ],
                            "billingAddress" => [
                                "id" => $customers[$key]["defaultBillingAddress"]["id"],
                                "countryId" => $customers[$key]["defaultBillingAddress"]["countryId"],
                                "salutationId" => $customers[$key]["defaultBillingAddress"]["salutationId"],
                                "firstName" => $customers[$key]["defaultBillingAddress"]["firstName"],
                                "lastName" => $customers[$key]["defaultBillingAddress"]["lastName"],
                                "street" => $customers[$key]["defaultBillingAddress"]["street"],
                                "zipcode" => $customers[$key]["defaultBillingAddress"]["zipcode"],
                                "city" => $customers[$key]["defaultBillingAddress"]["city"]
                            ],
                            "billingAddressId" => $customers[$key]["defaultBillingAddressId"],
                            "shippingAddressId" => $customers[$key]["defaultShippingAddressId"],
                            "currencyId" => "b7d2554b0ce847cd82f3ac9bd1c0dfca",
                            "languageId" => "2fbb5fe2e29a4d70aa5854ce7ce3e20b",
                            "salesChannelId" => "90ec3118032b4b25922bda8321fbedf2",
                            "orderDateTime" => new \DateTime($entry[0]['orderTime']),
                            "currencyFactor" => 1,
                            "stateId" => (isset($this->orderStates[$entry[0]["orderStatusID"]])) ? $this->orderStates[$entry[0]["orderStatusID"]] : $this->orderStates[2],
                            "orderCustomer" => [
                                "customerId" => $customers[$key]["id"],
                                "salutationId" => $customers[$key]["salutationId"],
                                "email" => $customers[$key]["email"],
                                "firstName" => $customers[$key]["firstName"],
                                "lastName" => $customers[$key]["lastName"],
                            ],
                            "customFields" => [
                                "importedViaAPI" => true
                            ],
                            "lineItems" => $products,
                            "transactions" => [
                                [
                                    "id" => Uuid::randomHex(),
                                    "amount" => [
                                        "unitPrice" => (float)$entry[0]["invoiceAmount"],
                                        "totalPrice" => (float)$entry[0]["invoiceAmount"],
                                        "quantity" => 1,
                                        "taxRules" => [
                                            [
                                                "taxRate" => $entry[0]["taxRate"],
                                                "percentage" => 100
                                            ]
                                        ],
                                        "calculatedTaxes" => []
                                    ],
                                    "paymentMethodId" => (isset($this->paymentMethods[$entry[0]["statusId"]])) ? $this->paymentMethods[$entry[0]["statusId"]] : $this->paymentMethods[5],
                                    "orderId" => $orderId,
                                    "stateId" => (isset($this->paymentState[$entry[0]["statusId"]])) ? $this->paymentState[$entry[0]["statusId"]] : $this->paymentState[12]
                                ],
                            ]