Place an Order
Important
To place an order you need the GraphQL Storefront module installed which is not available in a stable release as of this writing
The big picture
In order to successfully place an order via the GraphQL API you need to first
create a basket and fill with products
set a delivery address (in case it is different from invoice address)
set desired delivery option
set desired payment option
and finally place the order
Important
Ordered Basket will be removed on order creation!
Keep in mind, that you will need to send a valid JWT in Authorization header for any of the following queries or mutations.
Setup the basket
As there is no server side session available and the GraphQL API is as explicit
as possible, your first step towards placing an order is to create a basket via
the basketCreate
mutation:
mutation {
basketCreate(
basket: {
title: "myBasket",
public: false
}
){
id
}
}
{
"data": {
"basketCreate": {
"id": "310e50a2b1be309b255d70462cd75507"
}
}
}
It is your responsibility to store this ID locally, as you will need it to add products to this basket as well as to do any other preparation and the checkout.
If you happen to “forget” the ID, you can fetch all baskets belonging to a user
via the baskets
field in the customer
query.
This newly created basket is empty, so let’s add a product to it.
mutation {
basketAddProduct(
basketId: "310e50a2b1be309b255d70462cd75507",
productId:"05848170643ab0deb9914566391c0c63",
amount: 1
) {
items {
amount
product {
id
title
}
}
}
}
{
"data": {
"basketAddProduct": {
"items": [
{
"amount": 1,
"product": {
"id": "05848170643ab0deb9914566391c0c63",
"title": "Trapez ION MADTRIXX"
}
}
]
}
}
}
It is also possible for you to add a voucher to your basket. In order to do that, you need to know the number of an existing and available voucher that you could use. If the voucher does not exist or otherwise is not applicable, the API will return an error with a proper message.
mutation {
basketAddVoucher(
basketId: "310e50a2b1be309b255d70462cd75507",
voucherNumber: "MyVoucher"
)
{
id
vouchers{
number
}
}
}
In case the voucher exists and is applicable, the following response will be returned:
{
"data": {
"basketAddVoucher": {
"id": "e461fcdcda96b96b9a89a7d0fdc956eb",
"vouchers": [
{
"number": "MyVoucher"
}
]
}
}
}
Set the desired delivery option
In order to set your desired delivery option, you need to know the available
delivery options for this basket. You may query those via the
basketDeliveryMethods
query.
query {
basketDeliveryMethods(
basketId: "310e50a2b1be309b255d70462cd75507"
) {
id
title
}
}
{
"data": {
"basketDeliveryMethods": [
{
"id": "oxidstandard",
"title": "Standard"
}
]
}
}
Now that you know about the available options, you can set the desired delivery option.
mutation {
basketSetDeliveryMethod(
basketId: "310e50a2b1be309b255d70462cd75507",
deliveryMethodId:"oxidstandard"
) {
id
}
}
{
"data": {
"basketSetDeliveryMethod": {
"id": "310e50a2b1be309b255d70462cd75507"
}
}
}
Set the desired payment option
Orders need to be paid for, even in the case you place an order via
GraphQL. For choosing and setting a payment option, the workflow is the same as
with choosing the delivery option. Query available payment options for this
basket via the basketPayments
query and set the desired one via the
basketSetPayment
mutation.
query {
basketPayments(
basketId: "310e50a2b1be309b255d70462cd75507"
) {
id
title
}
}
{
"data": {
"basketPayments": [
{
"id": "oxidpayadvance",
"title": "Vorauskasse"
},
{
"id": "oxiddebitnote",
"title": "Bankeinzug/Lastschrift"
},
{
"id": "oxidcashondel",
"title": "Nachnahme"
}
]
}
}
mutation {
basketSetPayment(
basketId: "310e50a2b1be309b255d70462cd75507",
paymentId:"oxidpayadvance"
) {
payment {
id
title
}
}
}
{
"data": {
"basketSetPayment": {
"payment": {
"id": "oxidpayadvance",
"title": "Vorauskasse"
}
}
}
}
Finally placing the order
Now that the stage is set up, all that needs to be done is to place the order via
the placeOrder
mutation.
Important
Ordered Basket will be removed on order creation!
mutation {
placeOrder(
basketId:"310e50a2b1be309b255d70462cd75507"
) {
id
orderNumber
}
}
{
"data": {
"placeOrder": {
"id": "20804e7bef3ed3a1dda5b2506e914989",
"orderNumber": 1
}
}
}
You successfully placed your first order!
Important
In case that Users have to Confirm General Terms and Conditions during Check-Out option is active, placeOrder will fail with an error if confirmTermsAndConditions input field is missing or its value is false
mutation {
placeOrder(
basketId:"310e50a2b1be309b255d70462cd75507"
confirmTermsAndConditions: true
) {
id
orderNumber
}
}
{
"data": {
"placeOrder": {
"id": "20804e7bef3ed3a1dda5b2506e914989",
"orderNumber": 1
}
}
}