Shopify - Create Draft Orders
@sergio
code:
data:privatelast updated:4 years ago
today
Build integrations remarkably fast!
You're viewing a public workflow template.
Sign up to customize, add steps, modify code and more.
Join 1,000,000+ developers using the Pipedream platform
steps.
trigger
HTTP API
Deploy to generate unique URL
This workflow runs on Pipedream's servers and is triggered by HTTP / Webhook requests.
steps.
shopify_create_draft_order
Creates a draft order
auth
(auths.shopify)
params
Optional
code
async (params, auths) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
}
43
console.log(auths.shopify.oauth_access_token);

return await require("@pipedreamhq/platform").axios(this, {
  method: "post",
  url: `https://${auths.shopify.shop_id}.myshopify.com/admin/api/2020-01/draft_orders.json`,
  headers: {
    "X-Shopify-Access-Token": `${auths.shopify.oauth_access_token}`,
    "Content-Type": `application/json`,
  },
  data: {
      draft_order: {
      name: params.name,
      customer: typeof params.customer == 'undefined' ? params.customer : JSON.parse(params.customer),
      shipping_address: typeof params.shipping_address == 'undefined' ? params.shipping_address : JSON.parse(params.shipping_address),
      billing_address: typeof params.billing_address == 'undefined' ? params.billing_address : JSON.parse(params.billing_address),
      note: params.note,
      note_attributes: typeof params.note_attributes == 'undefined' ? params.note_attributes : JSON.parse(params.note_attributes),
      email: params.email,
      currency: params.currency,
      invoice_sent_at: params.invoice_sent_at,
      invoice_url: params.invoice_url,
      line_items: typeof params.line_items == 'undefined' ? params.line_items : JSON.parse(params.line_items),
      shipping_line: typeof params.shipping_line == 'undefined' ? params.shipping_line : JSON.parse(params.shipping_line),
      tags: params.tags,
      tax_exempt: params.tax_exempt,
      tax_exemptions: typeof params.tax_exemptions == 'undefined' ? params.tax_exemptions : JSON.parse(params.tax_exemptions),
      tax_lines:  typeof params.tax_lines == 'undefined' ? params.tax_lines : JSON.parse(params.tax_lines),
      applied_discount: typeof params.applied_discount == 'undefined' ? params.applied_discount : JSON.parse(params.applied_discount),
      taxes_included: params.taxes_included,
      total_tax: params.total_tax,
      subtotal_price: params.subtotal_price,
      total_price: params.total_price,
      completed_at: params.completed_at,
      created_at: params.created_at,
      updated_at: params.updated_at,
      status: params.status,
      use_customer_default_address: params.use_customer_default_address,
      customer_id : params.customer_id 
    }
  }
})