Price field in line_items for order_create mutation

Hey there

When creating an order, inside line_items the field price is required. What are these prices used for? Are they really required, or could we just send 0? If you need the actual prices, should they be for the entire quantity (so different depending if quantity is 1 or 3) or the price for one item? Should the prices include tax or not?

I’ve seen examples where people just posted 0 as a value.

Would be glad to know if and how to use that field.

Hey @Dev,

Thanks for reaching out and Welcome to our Developer Community!

It’s not necessarily required for the price field within line_items to have the corresponding value, although I do recommend it. The price here should represent only that line item and exclude tax. It’s possible to set this value to 0 and have the order price calculate using the other 4 price related fields.

Outside of the line_items field there are the fields: subtotal, total_tax, price under the shipping_lines field, and total_price. These fields will handle the tax and shipping fee, as well as set the subtotal before fees and ultimately the total price of the order.

Please let me know if you have any questions or concerns!

Best,
RayanP

Hey @sh-agent
Thank you for your quick reply!
I still don’t fully understand: where would the prices be used afterwards? Why do we need prices at all?

Best
Jakob

Hey Team,

Thanks for hanging in there!

The price totals would be used in the order webpage. For example if I ran this mutation:

mutation mutation_order_creat850 {
  order_create(
    data: {
      order_number: "R131"
      total_price: "26.00"
      total_tax:"5.00"
      subtotal: "20.00"
      shipping_lines: { title: "test", price: "1.00" }
      shipping_address: {
        first_name: ""
        last_name: ""
        address1: ""
        city: ""
        state: ""
        zip: ""
        country: ""
      }
      billing_address: {
        first_name: ""
        last_name: ""
        address1: ""
        city: ""
        state: ""
        zip: ""
        country: ""
      }
      line_items: {
        sku: "12345678"
        partner_line_item_id: "R124D21520211"
        quantity: 1
        price: "20.00"
      }
      address_is_business: true
    }
  ) {
    request_id
    complexity
    order {
      id
      legacy_id
      order_number
      partner_order_id
      address_is_business
      billing_address {
        first_name
        last_name
        address1
        city
        state
        zip
        country
      }
    }
  }
}

The Order Details in the webpage would look like this:

Inputting accurate price fields ensures that the order total is correct.

Please let me know if you have any questions or concerns.

Best,
RayanP

Thanks a lot, now I understand.

Best
Jakob

1 Like