这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@andrewjtech123
Copy link
Owner

use this PR for the third review

@andrewjtech123 andrewjtech123 mentioned this pull request Nov 18, 2016
@andrewjtech123
Copy link
Owner Author

related issue for instructions

#7

description: >
# Draft Orders API

A [Draft Order](https://help.shopify.com/manual/orders/create-orders) represents the status of an order before the customer has completed the checkout process. Using the Draft Orders API you can create a draft order and transition it to a completed order with great flexibility. The following flows are supported:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This top paragraph is great!

"before the customer has completed the checkout process" implies there is always a checkout, I'd be a bit more generic and say something that means "before the order has been completed" perhaps? Before the price, and line items, and exact contents of the order are finalized? the point is, its a draft if you can still change what the contents of the order are and what the exact pricing and payment method is.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on "before the order has been completed" as well. Though, in both ways it may get a little confusing with [Abandoned Checkouts] (https://help.shopify.com/api/reference/abandoned_checkouts)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A Draft Order represents the status of an order before the order is set to completed status.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to also add some more description content from the regular docs:
https://help.shopify.com/manual/orders/create-orders


## About Draft Orders

When using the [Orders API](https://help.shopify.com/api/reference/order) to create orders, no payment information is calcualted and no transaction is performed. With the Draft Orders API, on the other hand, you can create orders on which shipping, taxes and all total amounts are calculated by Shopify. This enables a wide range of use cases including applying one-off discounts to orders, offering special wholesale pricing, and returning draft order invoices for order printing.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calculated typo

Copy link

@dominiquesr dominiquesr Nov 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add creating custom orders or including custom product orders for customers as a possible enabled use case.

As in, I'm creating a blue tshirt with this logo that I don't usually use just for you.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the create orders docs:
use custom items to represent additional costs or products that aren't displayed in your inventory

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty much all of the examples from the create docs explain this really well:

  • create new orders in Shopify for sales you've made by phone, in person, or elsewhere
  • send invoices to customers to pay with a secure checkout link
  • use custom items to represent additional costs or products that aren't displayed in your inventory
  • re-create mistaken orders from any of your active sales channels
  • sell products at discount or wholesale rates
  • take pre-orders

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will use that list of use cases :)

@jordanliddle
Copy link

Can the version be removed here?:
21-54-wvd06-ylzol


* Create a draft order that calculates taxes and totals but accept payment from the customer outside of Shopify.
* Create a draft order (with taxes and totals) and email your customer a web checkout link to complete purchase and transition to a completed order.
* Use Draft Orders API in conjunction with the [Checkouts API](https://help.shopify.com/api/tutorials/sell-through-the-checkout-api) by created a Checkout object based on a draft order (Sales Channel SDK only). This enables a highly customizable experience for channels.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by creating*

Also, do any of the Alpha testers have access to the Sales Channel SDK? If not, should we remove reference to this for the alpha?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I have no idea, I'm pretty sure none of them are channels since most are still hand picked right?
I'm ok with in or out. Leaving it in might elicit some interesting discussion. Or some painful one. Whatever Jordan thinks!

schemes:
- https

host: your-store-domain.myshopify.com

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we use store or shop usually?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be store since the partners dashboard updated to "development stores"

/admin/draft_orders.json:
get:
summary: Retrieve draft orders
description: You can use this endpoint to return a list of draft order objects. This can be useful for a variety of applications including draft order printing. For `line_items` you can use the value of the `custom` field (true/false) to differentiate between custom line items and product variant line items.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This endpoint is used by any app that interacts with draft orders, not sure if calling out draft order printing makes sense. Also we don't call it draft order printing in shopify speak, since the shopify terminology is "creating orders" It would be for printing invoices

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the line_item description here instead of on the line_item field?

For line_itemsyou can use the value of thecustom field (true/false) to differentiate between custom line items and product variant line items.

A [Draft Order](https://help.shopify.com/manual/orders/create-orders) represents the status of an order before the customer has completed the checkout process. Using the Draft Orders API you can create a draft order and transition it to a completed order with great flexibility. The following flows are supported:

* Create a draft order that calculates taxes and totals but accept payment from the customer outside of Shopify.
* Create a draft order (with taxes and totals) and email your customer a web checkout link to complete purchase and transition to a completed order.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can either have Shopify email them a link, or use a draft order's invoice_url property to provide that link to the customer directly via email, chat,your app or any means that you are already using to communicate with the custom.

summary: Retrieve draft orders
description: You can use this endpoint to return a list of draft order objects. This can be useful for a variety of applications including draft order printing. For `line_items` you can use the value of the `custom` field (true/false) to differentiate between custom line items and product variant line items.
parameters:
- $ref: '#/parameters/fields'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These aren't implemented yet (the filters) we need a way to mark that they aren't there yet! They will be very soon, but not before alpha.

summary: Create a draft order
description: |

Using the Draft Orders API you can create draft orders using product variant line items, or your own custom line items. This enables you to create one-off products that exist outside of your regular inventory management system. To create a product variant draft order, simply specify a `variant_id` `quantity` and `discount` (if applicable). Create a custom line item by supplying `title`, `price`, `taxable` and `quantity`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create orders, in a draft state, maybe? I worry about using create draft orders when the feature in shopify is to create an order. but you're creating a draft order on the endpoint, so maybe we have to call it this?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would vote to keep it as "Create a draft order" - partly because the code examples will do just that, and the created resource will live in the Draft orders section of the admin.

Using the Draft Orders API you can create draft orders using product variant line items, or your own custom line items. This enables you to create one-off products that exist outside of your regular inventory management system. To create a product variant draft order, simply specify a `variant_id` `quantity` and `discount` (if applicable). Create a custom line item by supplying `title`, `price`, `taxable` and `quantity`.


| `Note`| The array of line items on a draft order must not contain a `variant_id` more than once. The data copied over from a variant upon creation of a line item is never subsequently updated. |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might actually let you create multiple line items with one variant id but it'll get rolled up automatically. would be good to test this for accuracy.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll test this in a few

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW - using the same variant_id more than once does not automatically roll all into a single line item. So the above statement is 👍

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the important point here from docs perspective is simply to state that each product variant line item must have a unique variant id.


#### About Custom Shipping Lines

Using the Draft Orders API provides you with the flexibility to fulfill order shipments either using Shopify or outside of Shopify. To fulfill your order within Shopify, you can send the `handle` of the `shipping_rate` set via the Shopify admin. For a custom shipping line, simply specify a `shipping_line` object with no `handle`. This is covered in more detail in the endpoint calls below.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shipping rates might not always be tied to fulfillments, since you might have a product fulfilled by vendor XYZ but the rate is provided by USPS. It doesn't 100% work that way in shopify right now since we can't have multi location but there's something about the way 'fulfill' is used in this sentence that seems incorrect.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also a custom shipping line means you're provicing a custom rate, when you go to the resulting order you can still create a shipping label for that order using canada post or whatever you have set up for your shop. This is what the customer pays, not necessary what you use to fulfilll.

source: |
curl -X POST -H "Content-Type: application/json" -H "Authorization: Basic YOUR-API-KEY=" -d '{
"id": 57760135,
"order_id": 57760134,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

order_id is read_only

curl -X POST -H "Content-Type: application/json" -H "Authorization: Basic YOUR-API-KEY=" -d '{
"id": 57760135,
"order_id": 57760134,
"name": "api created draft order",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name is read_only

"id": 57760135,
"order_id": 57760134,
"name": "api created draft order",
"customer": {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these fields except for customer { id } are read_only

"updated_at": "2016-11-18T17:10:07Z",
"tags": "string"
},
"shipping_address": "string",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has multiple fields, not just a string.
Billing address too. See the checkout API docs for examples.

"shipping_address": "string",
"billing_address": "string",
"note": "string",
"email": "string",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must be a valid email address

"billing_address": "string",
"note": "string",
"email": "string",
"currency": "string",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currency is read only

"note": "string",
"email": "string",
"currency": "string",
"invoice_sent_at": "2016-11-18T17:10:07Z",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

invoice_sent_at is read only

"invoice_url": "string",
"line_items": [
{
"custom": true,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

custom is read only

"email": "string",
"currency": "string",
"invoice_sent_at": "2016-11-18T17:10:07Z",
"invoice_url": "string",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

read only

"id": "string",
"vendor": "string",
"quantity": "string",
"gift_card": true,
Copy link

@dominiquesr dominiquesr Nov 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok... so, the doc has a column for what's read only, I'm not marking up the rest. You should review the design doc and remove anything from the create POST which is read_only.

Really a basic create post has line items, with a variant id and quantity OR a title, price and quantity

You can also look at the examples in the checkout API to see what makes sense. Just keep in mind they don't support custom line items and custom shipping rates.

value:
type: string
description: Error description.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo on "returned"

I'd like to get others' opinions (@dominiquesr) on the definition of the Error object. To me this still kind of reads that the object I'd be getting back would look like:

{ key: <field name>, value: <error> }

since key and value are defined as properties of the error object (or rather, properties of the additionalProperties), although I know we've already chatted about this and we're not sure there's a better way...

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tanner-rutgers do you think its more clear like this where I actually provide some sample values? Otherwise we can probably just remove the error schema all together and go with a simple description.

error schema

Copy link

@tanner-rutgers tanner-rutgers Nov 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrewjtech123 I don't think providing samples values in the schema makes it any more clear, just more confusing (now it makes me think there's always a property called shipping_line and a property called is_invalid)

I'm definitely leaning towards removing the error schema altogether and just having Errors with a good description of what they are (stating that it's just a list of key value pairs where the key is the field in error and the value is the error detail), along with an example, which I think can also just be in the description.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok agreed


'/admin/draft_orders/#{id}/send_invoice.json':
post:
summary: Create an invoice for a draft order

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Send, not create.

'/admin/draft_orders/#{id}/send_invoice.json':
post:
summary: Create an invoice for a draft order
description: You can use this endpoint to send your customer an invoice via email for thier draft order. The invoice contains a url link, enabling the customer to pay for the item using web checkout. Additionally, you can send a `draft_order_invoice` object in the body of the request to override any of the default email parameters for the invoice.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

their

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

draft order invoice isn't really an object, its a set of parameters to use to send the invoice

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will call it a hash instead, as per design doc

to:
type: string
description: >-
Email associated with the `draft_order_invoice`. If not specified, the email associated with the draft order, or the customer's email will be used instead. If no email address is specified an error is returned.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the draft order has no email address to use, then you must specify an email address, otherwise an error is returned.

Bad english, but the text right now implies an error exists all of the time.

custom_message:
type: string
description: An optional custom message inserted in the email's body.
checkout:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May want to reconsider including this in the docs as we previously discussed, depends on @jordanliddle

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting the 'custom_message' works fine for me!

parameters:
- name: draft_order_invoice
in: body
description: draft_order_invoice to post.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this description makes sense given that its not really an object?

name:
type: string
description: Name of the draft order.
readOnly: false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

read only...

items:
$ref: '#/definitions/tax_line'
readOnly: true
discount:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied_discount

description: Name of the draft order.
readOnly: false
customer:
type: object

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing description.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

description is included at the ref.

tags:
type: string
description: Tags are additional short descriptors, commonly used for filtering and searching, formatted as a string of comma-separated values. Each individual tag is limited to 40 characters in length.
tax_exempt:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

read only




shipping_rate:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be described in a public document that the checkout API also references. Why is this required for our docs, we don't use this?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed


shipping_rate:
type: object
required:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

required is invalid there's no such thing as a rate, only a line, right now.

required:
- title
- price
- tax_lines

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tax_line sis read only and not required. A read only field cannot be mandatory, its completely impossible. Can you cross reference?

shipping_line:
type: object
required:
- title

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

title and price are only mandatory when handle is not provided.

format: int64
description: The price of this shipping method.
readOnly: false
phone:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As previously requested, please remove. This is not implemented.

description: The phone number, if required as specified in the `shipping_rate`.
tax_lines:
type: array
readOnly: false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

read only true

- $ref: '#/definitions/shipping_line'
- type: object
required:
- title

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only handle is required

- price
- tax_lines
properties:
handle:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where are the other properties?

- $ref: '#/definitions/shipping_line'
- type: object
required:
- title

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only title and price are required

description: Nil for custom lines.


metafield:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this accurate or link to the actual metafields API documentation?


tax_line:
type: object
required:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nothing is required this entire object is read only

properties:
title:
type: string
description: The name of the tax.
Copy link

@dominiquesr dominiquesr Nov 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these the descriptions used on checkout and orders API reference?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes those descriptions are taken from checkout docs

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same text also appears in Orders docs

type: string
description: The amount of tax to be charged.

discount:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied_discount

discount:
type: object
required:
- description

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

description is not required, title, amount, value, value_type are required

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to confirm is value_type is actually required. Would be good to be consistent with checkout.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of title do you mean id ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no exposed id for applied_discount

value:
type: string
description: The value of the discount. If the type of the discount is `fixed_amount`, then this is a fixed dollar amount, if the type is `percentage`, then this is the percentage.
type:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

value_type

description: Customer to be associated with the draft order; however only the `id` can be set in order to associate the customer to the draft order. Setting the value to null removes the customer from the draft order.
properties:
accepts_marketing:
type: boolean

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these fields are read only

description: The type of the discount. Can be one of - `percentage` or `fixed_amount`. `Fixed_amount` is default value.
enum:
- percentage
- fixed_amount (default)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checked and we made a mistake and didn't update our design doc. There's no defaulting behaviour. This is a required field

type: string
description: The applied amount of the discount.

customer:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing the id field, not read only

@jordanliddle
Copy link

Not sure if this was already mentioned somewhere, but instead of GET, CREATE, DELETE, UPDATE - can we just use CRUD terms GET, POST, PUT, DELETE ?

@andrewjtech123
Copy link
Owner Author

@jordanliddle we can for sure use those CRUD terms if you want. We just need to decide on which terms we want and I will make it so :)

paths:
/admin/draft_orders.json:
get:
summary: Retrieve draft orders

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retrieve a list of draft orders

name: limit
in: query
required: false
description: Page size.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amount of results (default: 50) (maximum: 250)


#### About Custom Shipping Lines

Using the Draft Orders API provides you with the flexibility to fulfill order shipments either using Shopify or outside of Shopify. To fulfill your order within Shopify, you can send the `handle` of the `shipping_rate` set via the Shopify admin. For a custom shipping line, simply specify a `shipping_line` object with no `handle`. This is covered in more detail in the endpoint calls below.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The Draft Orders API provides"

readOnly: false
phone:
type: string
description: The phone number, if required as specified in the `shipping_rate`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dominiquesr what are some examples of where this would be used? Uber?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes exactly but its not implemented. Its required at the order level and I have to look into whether theres a ton of value to add it here, which I think there is, but would like to remove it for now or mark it not implemented



responses:
'200':

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this going to be 201? or 202?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

201, or sometimes 202 if polling required for shipping or taxes

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also 400 or 422

description: The value of the discount. If the type of the discount is `fixed_amount`, then this is a fixed dollar amount, if the type is `percentage`, then this is the percentage.
type:
type: string
description: The type of the discount. Can be one of - `percentage` or `fixed_amount`. `Fixed_amount` is default value.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed_amount

'/admin/draft_orders/#{id}/send_invoice.json':
post:
summary: Create an invoice for a draft order
description: You can use this endpoint to send your customer an invoice via email for thier draft order. The invoice contains a url link, enabling the customer to pay for the item using web checkout. Additionally, you can send a `draft_order_invoice` object in the body of the request to override any of the default email parameters for the invoice.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

their*

@dominiquesr
Copy link

For CRUD terms, maybe we can be consistent with current API docs?



responses:
'201':

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is 201, did you test? Also you can likely get a 422 for bad parameters, or 404 for wrong draft order id that cant be found

required: true
type: integer
responses:
'200':

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

400, 422, 404 most likely possible

type: integer
responses:
'200':
description: draft order

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

202 also possible

@dominiquesr
Copy link

We need to add a section which explains how 202 accepted works as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants