Hallo zusammen, ich möchte das Bundesland der Shoporder über die Shopware-Api auslesen, d.h. ich brauche die Tabellenfelder s_order_billingadress.stateID und s_order_shippingadress.stateID. Die Klassen der Rest API enthalten allerdings nur Country Informationen. Kann mir da jemand weiterhelfen? Schon mal vielen Dank vorab!
Hi, das Feld “stateId” gibt es in der API genauso wie das Feld “countryId”. Ein Problem kann ich hier nicht erkennen. Gruß Heiner
The information desired from orders is the following "state": { "id": 37, "name": "California" }
or "billing": { "id": xyz, "orderId": dddd, "customerId": ddd, "countryId": 2, "stateId": 5 ...
If „state“ or „stateId“ information is not available then the lack of information should be expressed in the following way "state": { "id": "", "name": "" }
or "state": {} }
or "billing": { "id": xyz, "orderId": dddd, "customerId": ddd, "countryId": 2, "stateId": 0, ...
or etc I was NOT able to find the field „state“ or „stateId“ in any of my samples GET /api/orders/{id} Json answers. This fact is apparently confirmed by official :shopware: documentation. In this example (modified to be anonymous) is impossible to find a „state“ field: ... "billing": { "id": xyz, "orderId": dddd, "customerId": ddd, "countryId": 2, "company": "sssssssssssssssssssss", "department": "", "salutation": "ms", "number": "", "firstName": "sssssssss", "lastName": "sssssssssss", "street": "sssssssssss", "streetNumber": "dd", "zipCode": "ddddd", "city": "sssssssssss", "phone": "", "fax": "", "vatId": "DEddddddddd", "country": { "id": 2, "name": "Deutschland", "iso": "DE", "isoName": "Deutschland", "position": 1, "description": "", "shippingFree": false, "taxFree": 0, "taxFreeUstId": 0, "taxFreeUstIdChecked": 0, "active": true, "iso3": "DEU", "displayStateInRegistration": false, "forceStateInRegistration": false, "areaId": 1 }, "attribute": { "id": xyz, "orderBillingId": xyz, "text1": "", "text2": "", "text3": "", "text4": "", "text5": "", "text6": "" } }, "shipping": { "id": xyz, "orderId": dddd, "countryId": 30, "customerId": ddd, "company": "", "department": "", "salutation": "mr", "firstName": "ssss", "lastName": "ssssssssss", "street": "sssssss", "streetNumber": "dsspdd", "zipCode": "ddddd", "city": "sssssss", "attribute": { "id": xyz, "orderShippingId": xyz, "text1": "", "text2": "", "text3": "", "text4": "", "text5": "", "text6": "" }, "country": { "id": 30, "name": "Poland", "iso": "PL", "isoName": "Poland", "position": 10, "description": "", "shippingFree": false, "taxFree": 0, "taxFreeUstId": 1, "taxFreeUstIdChecked": 0, "active": true, "iso3": "POL", "displayStateInRegistration": false, "forceStateInRegistration": false, "areaId": 2 } }, ...
Note for the casual reader: areaId is not stateId, it is the Country Area number (Germany/Europe/Rest of the World). Is it possible that Json answer’s structure change (not officially documented) if „displayStateInRegistration“: true, „forceStateInRegistration“: false, or „displayStateInRegistration“: true, „forceStateInRegistration“: true, ? In particular, is a field „state“: { „id“: , „name“: „“ } added somewhere in the Json answer? --------------------------------------------------------- Otherwise the user Dedackel (and every one else that desire to retrieve the StateId data from a Json GET’s answer /api/orders/{id}) should try to add/modify the PHP code realted to orders API. I have modified some Shopware’s PHP code before but I have never personally modified the PHP code related to an API. But maybe I could give some hints about a possible solution to the problem. Inside the following document from page 29 to page 35 (REST-API erweitern/Tax aka REST-API extension / Tax example), it is described a prodedure to add a new REST GET API related to Tax. The reader could check here to see that Tax is a REST API that do not exist by default. Another document (with more information) about API extension is the following :shopware: link. Sorry, because I have never used this procedure before, I don’t know if it is the right procedure 1) to use in the case is necessary to modify an already existing API (orders in this case: /api/orders/{id} ) or 2) if it is necessary (and possible) to create a duplicated version (but modified to include state field) of orders API (for example /api/orders2/{id} or /api/myorders/{id}). Best Regards -----