steampipe plugin install shopify

Table: shopify_draft_order - Query Shopify Draft Orders using SQL

A Draft Order in Shopify is a customizable order that allows merchants to create items and orders for customers that can be modified before purchase. It provides a way to create orders for customers that can be customized and updated before they are finalized. Draft Orders are used for orders that are not placed through the usual online checkout process, such as orders taken over the phone or for custom products.

Table Usage Guide

The shopify_draft_order table provides detailed insights into Draft Orders within Shopify. As an e-commerce manager or data analyst, explore draft order-specific details through this table, including customer information, line items, and associated metadata. Utilize it to uncover information about draft orders, such as those that have been pending for a long time, the common products in draft orders, and the verification of customer details.

Examples

Basic info

Explore which draft orders exist in your Shopify store, including customer details and shipping information. This can help you understand your pending transactions and plan your inventory and shipping strategies accordingly.

select
id,
name,
email,
customer,
billing_address,
shipping_address
from
shopify_draft_order;
select
id,
name,
email,
customer,
billing_address,
shipping_address
from
shopify_draft_order;

List all draft orders that have a status of "open" and include taxes in the product price

Determine the open draft orders which have incorporated taxes into the product pricing. This is particularly useful for financial analysis and tax auditing purposes.

select
id,
name,
email,
customer,
billing_address,
shipping_address,
status,
taxes_included
from
shopify_draft_order
where
status = 'open'
and taxes_included = true;
select
id,
name,
email,
customer,
billing_address,
shipping_address,
status,
taxes_included
from
shopify_draft_order
where
status = 'open'
and taxes_included = 1;

Find all draft orders with a specific tag

Discover the segments that contain draft orders tagged with discounts. This is beneficial for identifying potential sales opportunities or for tracking promotional campaigns.

select
id,
name,
email,
customer,
billing_address,
shipping_address,
status,
tags,
taxes_included
from
shopify_draft_order
where
tags like '%Discount%';
select
id,
name,
email,
customer,
billing_address,
shipping_address,
status,
tags,
taxes_included
from
shopify_draft_order
where
tags like '%Discount%';

Find all draft orders that contain a specific product in their line items

Discover the segments that contain a specific product in their draft orders, allowing you to analyze customer purchase behavior and product popularity. This information can be used to tailor marketing strategies and optimize inventory management.

select
id,
name,
email,
customer,
li ->> 'name' as product_name,
li ->> 'price' as product_price,
li ->> 'product_id' as product_id,
billing_address
from
shopify_draft_order,
jsonb_array_elements(line_items) as li
where
li ->> 'product_id' = '8264171716903';
select
id,
name,
email,
customer,
json_extract(li.value, '$.name') as product_name,
json_extract(li.value, '$.price') as product_price,
json_extract(li.value, '$.product_id') as product_id,
billing_address
from
shopify_draft_order,
json_each(line_items) as li
where
json_extract(li.value, '$.product_id') = '8264171716903';

List all the draft orders from a particular city

Discover the segments that contain draft orders from a particular city. This is useful for businesses that want to analyze their order patterns geographically, specifically focusing on areas with pending transactions.

select
id,
name,
email,
shipping_address
from
shopify_draft_order
where
shipping_address ->> 'city' = 'Toronto';
select
id,
name,
email,
shipping_address
from
shopify_draft_order
where
json_extract(shipping_address, '$.city') = 'Toronto';

List all draft orders for a particular customer

Explore all pending orders associated with a specific customer to keep track of their purchase history and manage their orders effectively. This can be particularly useful for businesses seeking to enhance their customer service and ensure timely order processing.

select
id,
name,
email,
customer,
billing_address,
shipping_address
from
shopify_draft_order
where
customer ->> 'first_name' = 'Karine'
and customer ->> 'last_name' = 'Ruby';
select
id,
name,
email,
customer,
billing_address,
shipping_address
from
shopify_draft_order
where
json_extract(customer, '$.first_name') = 'Karine'
and json_extract(customer, '$.last_name') = 'Ruby';

List the draft orders that have total tax greater than 100

Determine the areas in which draft orders have a tax amount exceeding 100. This can be useful for identifying potential high-value transactions or regions with higher tax rates.

select
id,
name,
email,
customer,
billing_address,
shipping_address,
total_tax
from
shopify_draft_order
where
(total_tax) :: numeric > 100;
select
id,
name,
email,
customer,
billing_address,
shipping_address,
total_tax
from
shopify_draft_order
where
CAST(total_tax AS REAL) > 100;

Schema for shopify_draft_order

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form, e.g. connection_name.
applied_discountjsonbDiscounts applied to the draft order.
billing_addressjsonbThe billing address for the draft order.
completed_attimestamp with time zoneThe time when the draft order was completed.
created_attimestamp with time zoneThe time when the draft order was created.
currencytextThe currency used for the draft order.
customerjsonbThe customer associated with the draft order.
emailtextThe email address associated with the draft order.
idbigint=The ID of the Shopify product.
invoice_sent_attimestamp with time zoneThe date and time the invoice was sent, if applicable.
invoice_urltextThe URL of the invoice, if applicable.
line_itemsjsonbThe line items in the draft order.
nametextThe name of the draft order.
notetextAn optional note attached to the draft order.
note_attributesjsonbAdditional metadata about the draft order.
order_idbigintThe ID of the draft order.
shipping_addressjsonbThe shipping address for the draft order.
shipping_linejsonbThe shipping details for the draft order.
statustextThe status of the draft order.
subtotal_pricedouble precisionThe total price of all the draft order's line items, before taxes and discounts.
tagstextTags associated with the draft order.
tax_exemptbooleanWhether the draft order is tax exempt.
tax_linesjsonbThe tax lines for the draft order.
taxes_includedbooleanWhether taxes are included in the product price.
titletextTitle of the resource.
total_pricetextThe total price of the draft order.
total_taxtextThe total amount of tax charged for the draft order.
updated_attimestamp with time zoneThe time when the draft order was last updated.
use_customer_default_addressbooleanWhether to use the customer's default address for shipping and/or billing.

Export

This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- shopify

You can pass the configuration to the command with the --config argument:

steampipe_export_shopify --config '<your_config>' shopify_draft_order