Shopify API接入

Shopify API接入


所有API的使用都是通过Shopify应用程序进行的,Shopify应用程序由店主为自己的商店创建,或者由Shopify合作伙伴创建,供其他店主使用:

有关该API的更多信息和详细文档,请访问 http://api.shopify.com

OAuth 验证

shopify api接入方式有三种:
  1. 通过公有应用接入,文档参考:通过 OAuth 对公共应用进行验证

    优缺点:

    ​ 一个公共的Shopify应用可以代表多个商店与Shopify API进行交互。要使用公共应用程序通过Shopify进行身份验证,您需要从合作伙伴信息中心生成凭据,然后使用它们来实现OAuth。但是公有应用必须通过shopify审核才可以使用。

    验证:

    import binascii
    import os
    
    import requests
    import shopify
    #应用凭据
    API_KEY = '461d8f56304d964a8f038c0d4070e2c3'
    API_SECRET = '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'
    SHOP_NAME='weshop1234'
    API_VERSION = '2020-04'
    
    shopify.Session.setup(api_key=API_KEY, secret=API_SECRET)
    shop_url = "{SHOP_NAME}.myshopify.com".format(SHOP_NAME=SHOP_NAME)
    api_version = '2020-10'
    state = binascii.b2a_hex(os.urandom(15)).decode("utf-8")
    print(state)
    redirect_uri = "http://47.94.130.206:5536/shop/callback"
    scopes = ['read_products', 'read_orders'] #权限
    
    newSession = shopify.Session(shop_url, api_version)
    auth_url = newSession.create_permission_url(scopes, redirect_uri, state)
    print(auth_url)
    
    #回调函数
    @shop_blue.route('/callback',methods=['GET'])
    def shopify_callback():
        response = {
            'status': 0,
            'error': None,
            'data': None,
            'msg': 'suc'
        }
    
        # 拿到临时code
        code = request.args.get('code', '')
        # 站名
        shop_name = request.args.get('shop', '')
        hmac = request.args.get('hmac', '')
        timestamp = request.args.get('timestamp', 0, type=int)
    
      
        params = {}
        params['code'] = code
        params['shop'] = shop_name
        params['hmac'] = hmac
        params['timestamp'] = timestamp
    
        shopify.Session.setup(api_key=API_KEY, secret=API_SECRET)
        session = shopify.Session(shop_name, version=SHOPIFY_API_VERSION)
        # 拿到token
        token = session.request_token(params)
        return {
            "shop_name":shop_name,
            "token":token
        }
    
    

    通过前端重定向或者浏览器访问auth_url地址,需要输入用户名密码,点击“授权”,会将临时code站名shophmacstate通过回调接口返回,然后便可获取永久授权码Token。类似于目前QQ、微信的授权页

    注意:

    ​ 回调函数的完整地址必须先加入到应用允许回调地址处。

    ​ [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-emRxPhJr-1604280661947)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20201027114102250.png)]

  2. 通过自定义应用接入,文档参考:通过 OAuth 对自定义应用进行验证

    优缺点:

    ​ 自定义Shopify应用程序可以代表单个商店与Shopify API交互。要使用自定义应用程序向Shopify进行身份验证,您需要从合作伙伴信息中心生成安装链接。商家使用该链接来进行OAuth流程并将其安装在他们的商店中。自定义应用不需要通过shopify审核。

    验证:

    ​ 同公共应用接入方式

  3. 通过专有应用接入,文档参考:通过 Shopify 后台对专有应用进行验证

    优缺点:

    ​ 专有Shopify应用可以代表一个商店与Shopify API交互。要使用专有应用程序向Shopify进行身份验证,您需要从Shopify管理员生成凭据,并在向Shopify的请求中提供这些凭据。专有应用也不需要通过shopify审核。

    验证:

import shopify

# Replace the following with your shop URL
shop_url = "https://{API_KEY}:{PASSWORD}@{SHOP_NAME}.myshopify.com/admin"
shopify.ShopifyResource.set_site(shop_url)

商品

#通过验证后
products = shopify.Product.find()
for prouduct in products:
    print(prouduct.attributes)
    for i in prouduct.variants:
        print(i.attributes)
prouduct attributes
{
	'id': 5932984696983,   //商品ID
	'title': 'Burton Custom Freestyle 151', //商品标题
	'body_html': '更改描述', //商品描述
	'vendor': 'weshop1234', //商品供应商
	'product_type': 'Snowboard', //商品类型
    'status': "active"//状态
	'created_at': '2020-10-23T17:58:46+08:00', 
	'handle': 'burton-custom-freestyle-151',
	'updated_at': '2020-10-27T09:17:07+08:00',
	'published_at': '2020-10-23T17:58:46+08:00', //发布时间
	'template_suffix': '', //模板
	'published_scope': 'web', //发布方式 web在线商店  global在线商店和销售点
	'tags': '',  //标签
	'admin_graphql_api_id': 'gid://shopify/Product/5932984696983',  //api管理ID
	'variants': //[variant(37227313561751)], 
    			[{
                    'id': 37227313561751,  
                    'title': 'Default Title',
                    'price': '13.90', //价格
                    'sku': '',//商店里的产品变种需要一个唯一标识符,这样才能完成服务
                    'position': 1, //仓位
                    'inventory_policy': 'deny', //当产品缺货时,是否允许客户下订单。有效值:deny 当前位置如果产品缺货,客户不得下订单,continue 当前位置如果产品缺货,客户可以下订单 
                    'compare_at_price': '9.90', //原价 调价调整或出售前项目的原始价格
                    'fulfillment_service': 'manual', //与产品变量相关的履行服务。有效值: 手册或履行服务的句柄。
                    'inventory_management': 'shopify',//跟踪产品变量库存项目数量的履行服务 :shopify您正在使用管理员自己跟踪库存,null 当前位置你没有跟踪变体的库存情况,
                    'option1': 'Default Title',
                    'option2': None,
                    'option3': None,
                    'created_at': '2020-10-23T17:58:46+08:00',
                    'updated_at': '2020-10-27T09:17:07+08:00',
                    'taxable': True, //是否收税
                    'barcode': '',//产品的条形码、 UPC 或 ISBN 号
                    'grams': 0, //产品变量的重量,以克为单位。
                    'image_id': None,
                    'weight': 0.0, //重量
                    'weight_unit': 'kg',//重量单位
                    'inventory_item_id': 39320107647127, //库存ID
                    'inventory_quantity': 5, //库存
                    'old_inventory_quantity': 5, // 旧存货数量
                    'requires_shipping': True, //需要运输
                    'admin_graphql_api_id': 'gid://shopify/ProductVariant/37227313561751' //api管理ID
                },
                 ],
    
	'options': //[option(7523204006039)],
                [{
                'id': 7523204006039,
                'product_id': 5932984696983,
                'name': 'Title',
                'position': 1,
                'values': ['Default Title']
            },],
	'images': [image(21951771607191)],
	'image': image(21951771607191)
}

添加商品

new_product = shopify.Product()
new_product.title = "Burton Custom Freestyle 151"
new_product.product_type = "Snowboard"
new_product.product_type = "Snowboard"
new_product.save()
方法:
1、find()

GET /admin/api/2020-10/products.json

Retrieves a list of products. 检索产品列表Note: 注意: As of version 2019-07, this endpoint implements pagination by using links that are provided in the response header. Sending the 在2019-07版本中,该端点通过使用响应头中提供的链接来实现分页page parameter will return an error. To learn more, see 参数将返回一个错误。要了解更多信息,请参见Making requests to paginated REST Admin API endpoints 对已分页的 REST 管理 API 端点发出请求.

ids 身份证Return only products specified by a comma-separated list of product IDs.只返回由逗号分隔的产品 id 列表指定的产品。
limit 限制Return up to this many results per page.每页返回这么多结果。(default: (默认值:50, maximum: ,最多:250)
since_id 自从.Restrict results to after the specified ID.将结果限制在指定 ID 之后。
title 标题Filter results by product title.按产品标题筛选结果。
vendor 厂商Filter results by product vendor.产品供应商的过滤结果。
handle 处理Filter results by product handle.按产品处理过滤结果。
product_type 产品 _ 类型Filter results by product type.按产品类型分列的过滤结果。
status 地位Return products by their status.按状态返回产品。(default: (默认值:active)active: Show only active products. 活跃的: 只显示活跃的产品archived: Show only archived products. 存档: 只显示存档产品draft: Show only draft products. 草稿: 只显示草稿产品
collection_id 集合 idFilter results by product collection ID.按产品集合 ID 筛选结果。
created_at_min 创建 at _ minShow products created after date. (format: 2014-04-25T16:15:47-04:00)显示日期后创建的产品。(格式: 2014-04-25T16:15:47-04:00)
created_at_max 创建最大Show products created before date. (format: 2014-04-25T16:15:47-04:00)显示在日期前创建的产品。(格式: 2014-04-25T16:15:47-04:00)
updated_at_min 更新时间: 2012年10月12日Show products last updated after date. (format: 2014-04-25T16:15:47-04:00)展示产品最后更新日期后。(格式: 2014-04-25T16:15:47-04:00)
updated_at_max 更新时间: 最高时间Show products last updated before date. (format: 2014-04-25T16:15:47-04:00)展示产品最后更新日期前。(格式: 2014-04-25T16:15:47-04:00)
published_at_min 出版时间: 2012年10月15日Show products published after date. (format: 2014-04-25T16:15:47-04:00)展示过期出版的产品(格式: 2014-04-25T16:15:47-04:00)
published_at_max 最大限度地发表Show products published before date. (format: 2014-04-25T16:15:47-04:00)展示在日期前出版的产品。(格式: 2014-04-25T16:15:47-04:00)
published_status 发布状态Return products by their published status按发布状态返回产品(default: (默认值:any)published: Show only published products. 只展示已出版的产品unpublished: Show only unpublished products. 未发布的: 只显示未发布的产品any: Show all products. 任何: 展示所有产品
fields 田野Show only certain fields, specified by a comma-separated list of field names.只显示由以逗号分隔的字段名列表指定的某些字段。
presentment_currencies 货币Return presentment prices in only certain currencies, specified by a comma-separated list of ISO 4217 currency codes.仅以某些货币提示价格,由以逗号分隔的 ISO 4217货币代码列表指定。

Shopify API 允许您对 Product 资源执行以下操作。这些一般行动的更详细的版本可以提供:

订单

#参考文档https://shopify.dev/docs/admin-api/rest/reference/orders/order
#通过验证后
orders = shopify.Order.find()
for order in orders:
    print(order.attributes)
    for i in order.variants:
        print(i.attributes)
order attributes
{
	'id': 2900896612503,
	'email': '',
	'closed_at': None,//关闭时间
	'created_at': '2020-10-27T14:34:01+08:00',
	'updated_at': '2020-10-27T14:34:02+08:00',
	'number': 1, 
	'note': '这里是备注',
	'token': '3378ad6d7b57251ed0ab48f2bf556989',
	'gateway': 'manual', //支付通道:人工
	'test': False,
	'total_price': '16.26', //总计
	'subtotal_price': '13.90', //小计  = 总价 - 折扣
	'total_weight': 0, //总重
	'total_tax': '2.36',//税费
	'taxes_included': False, //含税
	'currency': 'CNY', //币种
	'financial_status': 'pending', //pending待处理,authorized已授权,partially_paid 部分支付,paid已支付,partially_refunded已部分退款,refunded已退款,voided作废
	'confirmed': True, //是否确认
	'total_discounts': '0.00', //折扣
	'total_line_items_price': '13.90', //商品总价
	'cart_token': None, //与订单关联的购物车的ID
	'buyer_accepts_marketing': False, //买家接受营销
	'name': '#1001',
	'referring_site': None, //参考网站
	'landing_site': None, //登录网址
	'cancelled_at': None,  //取消订单的日期和时间
	'cancel_reason': None, //取消原因  customer客户:客户取消了订单, fraud欺诈:订单是欺诈性的,inventory库存:订单中的商品库存不足,declined拒绝:付款被拒绝,other其他
	'total_price_usd': '2.43',//总美金
	'checkout_token': None, //检验token
	'reference': None, //引用
	'user_id': 65982202007,
	'location_id': 56822038679,
	'source_identifier': None, //源标识符
	'source_url': None, //来源地址
	'processed_at': '2020-10-27T14:34:01+08:00',
	'device_id': None, //设备id
	'phone': None,//手机
	'customer_locale': None, //客户地区
	'app_id': 1354745,
	'browser_ip': None,
	'landing_site_ref': None,
	'order_number': 1001, //订单号
	'discount_applications': [],//折扣应用程序
	'discount_codes': [],//折扣代码
	'note_attributes': [],
	'payment_gateway_names': ['manual'],
	'processing_method': 'manual',
	'checkout_id': None,
	'source_name': 'shopify_draft_order', //来源名字:shopify草稿订单
	'fulfillment_status': None, //fulfilled已完成,null未发货,partial部分发货,restocked缺货
	'tax_lines': [tax_line(None)], //税费对象数组
	'tags': '',
	'contact_email': None,
	'order_status_url': 'https://weshop1234.myshopify.com/50213322903/orders/3378ad6d7b57251ed0ab48f2bf556989/authenticate?key=7ae88aece4fe483232fc021626c7b03f',
	'presentment_currency': 'CNY',
	'total_line_items_price_set': total_line_items_price_set(None), //总行项目价格设置
	'total_discounts_set': total_discounts_set(None), //总折扣设置
	'total_shipping_price_set': total_shipping_price_set(None), //总运费
	'subtotal_price_set': subtotal_price_set(None), //小计价格设置
	'total_price_set': total_price_set(None), //总价格设置
	'total_tax_set': total_tax_set(None), //总税费设置
	'line_items': //[line_item(6249679061143)],
                    [{
                    'id': 6249750626455,
                    'variant_id': 37227313561751,
                    'title': 'Burton Custom Freestyle 151',
                    'quantity': 1,//数量
                    'sku': '',
                    'variant_title': None,
                    'vendor': 'weshop1234',
                    'fulfillment_service': 'manual',
                    'product_id': 5932984696983,
                    'requires_shipping': True,
                    'taxable': True,
                    'gift_card': False,
                    'name': 'Burton Custom Freestyle 151',
                    'variant_inventory_management': 'shopify',
                    'properties': [],
                    'product_exists': True,
                    'fulfillable_quantity': 1,//发货数量
                    'grams': 0,
                    'price': '13.90',
                    'total_discount': '0.00',
                    'fulfillment_status': None,
                    'price_set': price_set(None),
                    'total_discount_set': total_discount_set(None),
                    'discount_allocations': [discount_allocation(None)],
                    'admin_graphql_api_id': 'gid://shopify/LineItem/6249750626455',
                    'tax_lines': [tax_line(None)]
                },],
	'fulfillments': [ //物流 保存物流记录
    				{
                        'id': 2720493699223,
                        'status': 'cancelled',
                        'created_at': '2020-10-27T15:07:44+08:00',
                        'service': 'manual',
                        'updated_at': '2020-10-27T15:09:48+08:00',
                        'tracking_company': None,
                        'shipment_status': None,
                        'location_id': 56822038679,
                        'line_items': [line_item(6249750626455)],
                        'tracking_number': None,
                        'tracking_numbers': [],
                        'tracking_url': None,
                        'tracking_urls': [],
                        'receipt': receipt(None),
                        'name': '#1003.1',
                        'admin_graphql_api_id': 'gid://shopify/Fulfillment/2720493699223'
                    },
    		],
	'refunds': [], //退款详情
	'total_tip_received': '0.0', //总收款
	'admin_graphql_api_id': 'gid://shopify/Order/2900896612503',
	'shipping_lines': [  //配送相关信息
                    {
                        'id': 2343690797207,
                        'title': '运费',
                        'price': '10.00',
                        'code': 'custom',
                        'source': 'shopify',
                        'phone': None,
                        'requested_fulfillment_service_id': None,
                        'delivery_category': None,
                        'carrier_identifier': None,
                        'discounted_price': '10.00',
                        'price_set': price_set(None),
                        'discounted_price_set': discounted_price_set(None),
                        'discount_allocations': [],
                        'tax_lines': []
            	}],
    //已付款则会出现以下信息
    'current_total_price': '32.52',
	'current_total_price_set': current_total_price_set(None),
	'total_outstanding': '16.26',
	'current_subtotal_price': '27.80',
	'current_subtotal_price_set': current_subtotal_price_set(None),
	'current_total_tax': '4.72',
	'current_total_tax_set': current_total_tax_set(None),
	'current_total_discounts': '0.00',
	'current_total_discounts_set': current_total_discounts_set(None)
}
方法:
1、find()

Retrieves a list of orders. 检索订单列表Note: 注意: As of version 2019-10, this endpoint implements pagination by using links that are provided in the response header. Sending the 在2019-10版本中,该端点通过使用响应头中提供的链接来实现分页page parameter will return an error. To learn more, see 参数将返回一个错误。要了解更多信息,请参见Making requests to paginated REST Admin API endpoints 对已分页的 REST 管理 API 端点发出请求.

查询字段描述
idsRetrieve only orders specified by a comma-separated list of order IDs.仅检索由以逗号分隔的顺序 id 列表指定的顺序。
limit 条数限制The maximum number of results to show on a page.在页面上显示的最大结果数。(default: (默认值:50, maximum: ,最多:250)
since_id ID起始.Show orders after the specified ID.在指定 ID 后显示订单。
created_at_min 最小创建时间Show orders created at or after date (format: 2014-04-25T16:15:47-04:00).显示在日期或之后创建的订单(格式: 2014-04-25T16:15:47-04:00)。
created_at_max 最大创建时间Show orders created at or before date (format: 2014-04-25T16:15:47-04:00).显示在日期或之前生成的订单(格式: 2014-04-25T16:15:47-04:00)。
updated_at_min 最小更新时间Show orders last updated at or after date (format: 2014-04-25T16:15:47-04:00).展示订单最后更新日期或之后(格式: 2014-04-25T16:15:47-04:00)。
updated_at_max 更新时间: 最大时间Show orders last updated at or before date (format: 2014-04-25T16:15:47-04:00).最后更新日期(格式: 2014-04-25T16:15:47-04:00)。
processed_at_min 最小审核时间Show orders imported at or after date (format: 2014-04-25T16:15:47-04:00).显示在日期或之后输入的订单(格式: 2014-04-25T16:15:47-04:00)。
processed_at_max 最大审核时间Show orders imported at or before date (format: 2014-04-25T16:15:47-04:00).显示在日期或之前输入的订单(格式: 2014-04-25T16:15:47-04:00)。
attribution_app_id app id 归属Show orders attributed to a certain app, specified by the app ID. Set as current to show orders for the app currently consuming the API.显示属于某个应用程序的订单,由应用程序 ID 指定。设置为 current 以显示当前使用 API 的应用程序的订单。
status 订单状态Filter orders by their status.根据订单的状态过滤订单。(default: (默认值:open) open: Show only open orders. 打开: 只显示未结订单closed: Show only closed orders. 关闭: 只显示关闭的订单cancelled: Show only canceled orders. 取消: 只显示取消的订单any: Show orders of any status, including archived orders. 任何: 显示任何状态的订单,包括存档的订单
financial_status 付款状态Filter orders by their financial status.根据订单的财务状况过滤订单。(default: (默认值:any) authorized: Show only authorized orders 授权: 只显示授权的命令pending: Show only pending orders 挂起: 只显示挂起的命令paid: Show only paid orders 付费: 只显示付费订单partially_paid: Show only partially paid orders 部分付费: 只显示部分付费订单refunded: Show only refunded orders 退款: 只显示退款订单voided: Show only voided orders 无效的: 只显示无效的命令partially_refunded: Show only partially refunded orders 部分退款: 只显示部分退款订单any: Show orders of any financial status. 任何: 显示任何财务状况的订单unpaid: Show authorized and partially paid orders. 未付款: 显示授权订单和部分付款订单
fulfillment_status 发货状态Filter orders by their fulfillment status.根据订单的完成情况过滤订单。(default: (默认值:any)shipped: Show orders that have been shipped. Returns orders with fulfillment_status of fulfilled. 发货: 显示已经发货的订单。返回满足fulfilled状态的订单partial: Show partially shipped orders. 部分: 显示部分发货订单unshipped: Show orders that have not yet been shipped. Returns orders with fulfillment_status of null. 未发货: 显示尚未发货的订单。返回满足 _ 状态为 null 的订单any: Show orders of any fulfillment status. 任何: 显示任何完成状态的订单unfulfilled: Returns orders with fulfillment_status of null or partial. 返回 状态为 null 或partial的订单
fields 字段Retrieve only certain fields, specified by a comma-separated list of fields names.只检索由逗号分隔的字段名列表指定的某些字段。
fields 字段:

Retrieve all orders 检索所有订单

GET /admin/api/unstable/orders.json?status=any
HTTP/1.1 200 OK
{
    "orders":[
        {
            "id":450789469,
            "email":"bob.norman@hostmail.com",
            "closed_at":null,
            "created_at":"2008-01-10T11:00:00-05:00",
            "updated_at":"2008-01-10T11:00:00-05:00",
            "number":1,
            "note":null,
            "token":"b1946ac92492d2347c6235b4d2611184",
            "gateway":"authorize_net",
            "test":false,
            "total_price":"598.94",
            "subtotal_price":"597.00",
            "total_weight":0,
            "total_tax":"11.94",
            "taxes_included":false,
            "currency":"USD",
            "financial_status":"partially_refunded",
            "confirmed":true,
            "total_discounts":"10.00",
            "total_line_items_price":"597.00",
            "cart_token":"68778783ad298f1c80c3bafcddeea02f",
            "buyer_accepts_marketing":false,
            "name":"#1001",
            "referring_site":"http://www.otherexample.com",
            "landing_site":"http://www.example.com?source=abc",
            "cancelled_at":null,
            "cancel_reason":null,
            "total_price_usd":"598.94",
            "checkout_token":"bd5a8aa1ecd019dd3520ff791ee3a24c",
            "reference":"fhwdgads",
            "user_id":null,
            "location_id":null,
            "source_identifier":"fhwdgads",
            "source_url":null,
            "processed_at":"2008-01-10T11:00:00-05:00",
            "device_id":null,
            "phone":"+557734881234",
            "customer_locale":null,
            "app_id":null,
            "browser_ip":"0.0.0.0",
            "landing_site_ref":"abc",
            "order_number":1001,
            "discount_applications":[
                Object{...}
            ],
            "discount_codes":[
                Object{...}
            ],
            "note_attributes":[
                Object{...},
                Object{...}
            ],
            "payment_gateway_names":[
                "bogus"
            ],
            "processing_method":"direct",
            "checkout_id":901414060,
            "source_name":"web",
            "fulfillment_status":null,
            "tax_lines":[
                {
                    "price":"11.94",
                    "rate":0.06,
                    "title":"State Tax",
                    "price_set":{
                        "shop_money":{
                            "amount":"11.94",
                            "currency_code":"USD"
                        },
                        "presentment_money":{
                            "amount":"11.94",
                            "currency_code":"USD"
                        }
                    }
                }
            ],
            "tags":"",
            "contact_email":"bob.norman@hostmail.com",
            "order_status_url":"https://apple.myshopify.com/690933842/orders/b1946ac92492d2347c6235b4d2611184/authenticate?key=40e972daf10fcb0610e35c80aa07b4f6",
            "presentment_currency":"USD",
            "total_line_items_price_set":{
                "shop_money":{
                    "amount":"597.00",
                    "currency_code":"USD"
                },
                "presentment_money":{
                    "amount":"597.00",
                    "currency_code":"USD"
                }
            },
            "total_discounts_set":{
                "shop_money":{
                    "amount":"10.00",
                    "currency_code":"USD"
                },
                "presentment_money":{
                    "amount":"10.00",
                    "currency_code":"USD"
                }
            },
            "total_shipping_price_set":{
                "shop_money":{
                    "amount":"0.00",
                    "currency_code":"USD"
                },
                "presentment_money":{
                    "amount":"0.00",
                    "currency_code":"USD"
                }
            },
            "subtotal_price_set":{
                "shop_money":{
                    "amount":"597.00",
                    "currency_code":"USD"
                },
                "presentment_money":{
                    "amount":"597.00",
                    "currency_code":"USD"
                }
            },
            "total_price_set":{
                "shop_money":{
                    "amount":"598.94",
                    "currency_code":"USD"
                },
                "presentment_money":{
                    "amount":"598.94",
                    "currency_code":"USD"
                }
            },
            "total_tax_set":{
                "shop_money":{
                    "amount":"11.94",
                    "currency_code":"USD"
                },
                "presentment_money":{
                    "amount":"11.94",
                    "currency_code":"USD"
                }
            },
            "line_items":[
                {
                    "id":466157049,
                    "variant_id":39072856,
                    "title":"IPod Nano - 8gb",
                    "quantity":1,
                    "sku":"IPOD2008GREEN",
                    "variant_title":"green",
                    "vendor":null,
                    "fulfillment_service":"manual",
                    "product_id":632910392,
                    "requires_shipping":true,
                    "taxable":true,
                    "gift_card":false,
                    "name":"IPod Nano - 8gb - green",
                    "variant_inventory_management":"shopify",
                    "properties":[
                        {
                            "name":"Custom Engraving Front",
                            "value":"Happy Birthday"
                        },
                        {
                            "name":"Custom Engraving Back",
                            "value":"Merry Christmas"
                        }
                    ],
                    "product_exists":true,
                    "fulfillable_quantity":1,
                    "grams":200,
                    "price":"199.00",
                    "total_discount":"0.00",
                    "fulfillment_status":null,
                    "price_set":{
                        "shop_money":{
                            "amount":"199.00",
                            "currency_code":"USD"
                        },
                        "presentment_money":{
                            "amount":"199.00",
                            "currency_code":"USD"
                        }
                    },
                    "total_discount_set":{
                        "shop_money":{
                            "amount":"0.00",
                            "currency_code":"USD"
                        },
                        "presentment_money":{
                            "amount":"0.00",
                            "currency_code":"USD"
                        }
                    },
                    "discount_allocations":[
                        {
                            "amount":"3.34",
                            "discount_application_index":0,
                            "amount_set":{
                                "shop_money":{
                                    "amount":"3.34",
                                    "currency_code":"USD"
                                },
                                "presentment_money":{
                                    "amount":"3.34",
                                    "currency_code":"USD"
                                }
                            }
                        }
                    ],
                    "duties":[

                    ],
                    "admin_graphql_api_id":"gid://shopify/LineItem/466157049",
                    "tax_lines":[
                        {
                            "title":"State Tax",
                            "price":"3.98",
                            "rate":0.06,
                            "price_set":{
                                "shop_money":{
                                    "amount":"3.98",
                                    "currency_code":"USD"
                                },
                                "presentment_money":{
                                    "amount":"3.98",
                                    "currency_code":"USD"
                                }
                            }
                        }
                    ]
                },
                {
                    "id":518995019,
                    "variant_id":49148385,
                    "title":"IPod Nano - 8gb",
                    "quantity":1,
                    "sku":"IPOD2008RED",
                    "variant_title":"red",
                    "vendor":null,
                    "fulfillment_service":"manual",
                    "product_id":632910392,
                    "requires_shipping":true,
                    "taxable":true,
                    "gift_card":false,
                    "name":"IPod Nano - 8gb - red",
                    "variant_inventory_management":"shopify",
                    "properties":[

                    ],
                    "product_exists":true,
                    "fulfillable_quantity":1,
                    "grams":200,
                    "price":"199.00",
                    "total_discount":"0.00",
                    "fulfillment_status":null,
                    "price_set":{
                        "shop_money":{
                            "amount":"199.00",
                            "currency_code":"USD"
                        },
                        "presentment_money":{
                            "amount":"199.00",
                            "currency_code":"USD"
                        }
                    },
                    "total_discount_set":{
                        "shop_money":{
                            "amount":"0.00",
                            "currency_code":"USD"
                        },
                        "presentment_money":{
                            "amount":"0.00",
                            "currency_code":"USD"
                        }
                    },
                    "discount_allocations":[
                        {
                            "amount":"3.33",
                            "discount_application_index":0,
                            "amount_set":{
                                "shop_money":{
                                    "amount":"3.33",
                                    "currency_code":"USD"
                                },
                                "presentment_money":{
                                    "amount":"3.33",
                                    "currency_code":"USD"
                                }
                            }
                        }
                    ],
                    "duties":[

                    ],
                    "admin_graphql_api_id":"gid://shopify/LineItem/518995019",
                    "tax_lines":[
                        {
                            "title":"State Tax",
                            "price":"3.98",
                            "rate":0.06,
                            "price_set":{
                                "shop_money":{
                                    "amount":"3.98",
                                    "currency_code":"USD"
                                },
                                "presentment_money":{
                                    "amount":"3.98",
                                    "currency_code":"USD"
                                }
                            }
                        }
                    ]
                },
                {
                    "id":703073504,
                    "variant_id":457924702,
                    "title":"IPod Nano - 8gb",
                    "quantity":1,
                    "sku":"IPOD2008BLACK",
                    "variant_title":"black",
                    "vendor":null,
                    "fulfillment_service":"manual",
                    "product_id":632910392,
                    "requires_shipping":true,
                    "taxable":true,
                    "gift_card":false,
                    "name":"IPod Nano - 8gb - black",
                    "variant_inventory_management":"shopify",
                    "properties":[

                    ],
                    "product_exists":true,
                    "fulfillable_quantity":1,
                    "grams":200,
                    "price":"199.00",
                    "total_discount":"0.00",
                    "fulfillment_status":null,
                    "price_set":{
                        "shop_money":{
                            "amount":"199.00",
                            "currency_code":"USD"
                        },
                        "presentment_money":{
                            "amount":"199.00",
                            "currency_code":"USD"
                        }
                    },
                    "total_discount_set":{
                        "shop_money":{
                            "amount":"0.00",
                            "currency_code":"USD"
                        },
                        "presentment_money":{
                            "amount":"0.00",
                            "currency_code":"USD"
                        }
                    },
                    "discount_allocations":[
                        {
                            "amount":"3.33",
                            "discount_application_index":0,
                            "amount_set":{
                                "shop_money":{
                                    "amount":"3.33",
                                    "currency_code":"USD"
                                },
                                "presentment_money":{
                                    "amount":"3.33",
                                    "currency_code":"USD"
                                }
                            }
                        }
                    ],
                    "duties":[

                    ],
                    "admin_graphql_api_id":"gid://shopify/LineItem/703073504",
                    "tax_lines":[
                        {
                            "title":"State Tax",
                            "price":"3.98",
                            "rate":0.06,
                            "price_set":{
                                "shop_money":{
                                    "amount":"3.98",
                                    "currency_code":"USD"
                                },
                                "presentment_money":{
                                    "amount":"3.98",
                                    "currency_code":"USD"
                                }
                            }
                        }
                    ]
                }
            ],
            "fulfillments":[
                {
                    "id":255858046,
                    "order_id":450789469,
                    "status":"failure",
                    "created_at":"2020-10-22T10:31:33-04:00",
                    "service":"manual",
                    "updated_at":"2020-10-22T10:31:33-04:00",
                    "tracking_company":"USPS",
                    "shipment_status":null,
                    "location_id":905684977,
                    "line_items":[
                        {
                            "id":466157049,
                            "variant_id":39072856,
                            "title":"IPod Nano - 8gb",
                            "quantity":1,
                            "sku":"IPOD2008GREEN",
                            "variant_title":"green",
                            "vendor":null,
                            "fulfillment_service":"manual",
                            "product_id":632910392,
                            "requires_shipping":true,
                            "taxable":true,
                            "gift_card":false,
                            "name":"IPod Nano - 8gb - green",
                            "variant_inventory_management":"shopify",
                            "properties":[
                                {
                                    "name":"Custom Engraving Front",
                                    "value":"Happy Birthday"
                                },
                                {
                                    "name":"Custom Engraving Back",
                                    "value":"Merry Christmas"
                                }
                            ],
                            "product_exists":true,
                            "fulfillable_quantity":1,
                            "grams":200,
                            "price":"199.00",
                            "total_discount":"0.00",
                            "fulfillment_status":null,
                            "price_set":{
                                "shop_money":{
                                    "amount":"199.00",
                                    "currency_code":"USD"
                                },
                                "presentment_money":{
                                    "amount":"199.00",
                                    "currency_code":"USD"
                                }
                            },
                            "total_discount_set":{
                                "shop_money":{
                                    "amount":"0.00",
                                    "currency_code":"USD"
                                },
                                "presentment_money":{
                                    "amount":"0.00",
                                    "currency_code":"USD"
                                }
                            },
                            "discount_allocations":[
                                {
                                    "amount":"3.34",
                                    "discount_application_index":0,
                                    "amount_set":{
                                        "shop_money":{
                                            "amount":"3.34",
                                            "currency_code":"USD"
                                        },
                                        "presentment_money":{
                                            "amount":"3.34",
                                            "currency_code":"USD"
                                        }
                                    }
                                }
                            ],
                            "duties":[

                            ],
                            "admin_graphql_api_id":"gid://shopify/LineItem/466157049",
                            "tax_lines":[
                                {
                                    "title":"State Tax",
                                    "price":"3.98",
                                    "rate":0.06,
                                    "price_set":{
                                        "shop_money":{
                                            "amount":"3.98",
                                            "currency_code":"USD"
                                        },
                                        "presentment_money":{
                                            "amount":"3.98",
                                            "currency_code":"USD"
                                        }
                                    }
                                }
                            ]
                        }
                    ],
                    "tracking_number":"1Z2345",
                    "tracking_numbers":[
                        "1Z2345"
                    ],
                    "tracking_url":"https://tools.usps.com/go/TrackConfirmAction_input?qtc_tLabels1=1Z2345",
                    "tracking_urls":[
                        "https://tools.usps.com/go/TrackConfirmAction_input?qtc_tLabels1=1Z2345"
                    ],
                    "receipt":{
                        "testcase":true,
                        "authorization":"123456"
                    },
                    "name":"#1001.0",
                    "admin_graphql_api_id":"gid://shopify/Fulfillment/255858046"
                }
            ],
            "refunds":[
                {
                    "id":509562969,
                    "order_id":450789469,
                    "created_at":"2020-10-22T10:31:33-04:00",
                    "note":"it broke during shipping",
                    "user_id":799407056,
                    "processed_at":"2020-10-22T10:31:33-04:00",
                    "restock":true,
                    "duties":[

                    ],
                    "total_duties_set":{
                        "shop_money":{
                            "amount":"0.00",
                            "currency_code":"USD"
                        },
                        "presentment_money":{
                            "amount":"0.00",
                            "currency_code":"USD"
                        }
                    },
                    "admin_graphql_api_id":"gid://shopify/Refund/509562969",
                    "refund_line_items":[
                        {
                            "id":104689539,
                            "quantity":1,
                            "line_item_id":703073504,
                            "location_id":487838322,
                            "restock_type":"legacy_restock",
                            "subtotal":195.67,
                            "total_tax":3.98,
                            "subtotal_set":{
                                "shop_money":{
                                    "amount":"195.67",
                                    "currency_code":"USD"
                                },
                                "presentment_money":{
                                    "amount":"195.67",
                                    "currency_code":"USD"
                                }
                            },
                            "total_tax_set":{
                                "shop_money":{
                                    "amount":"3.98",
                                    "currency_code":"USD"
                                },
                                "presentment_money":{
                                    "amount":"3.98",
                                    "currency_code":"USD"
                                }
                            },
                            "line_item":{
                                "id":703073504,
                                "variant_id":457924702,
                                "title":"IPod Nano - 8gb",
                                "quantity":1,
                                "sku":"IPOD2008BLACK",
                                "variant_title":"black",
                                "vendor":null,
                                "fulfillment_service":"manual",
                                "product_id":632910392,
                                "requires_shipping":true,
                                "taxable":true,
                                "gift_card":false,
                                "name":"IPod Nano - 8gb - black",
                                "variant_inventory_management":"shopify",
                                "properties":[

                                ],
                                "product_exists":true,
                                "fulfillable_quantity":1,
                                "grams":200,
                                "price":"199.00",
                                "total_discount":"0.00",
                                "fulfillment_status":null,
                                "price_set":{
                                    "shop_money":{
                                        "amount":"199.00",
                                        "currency_code":"USD"
                                    },
                                    "presentment_money":{
                                        "amount":"199.00",
                                        "currency_code":"USD"
                                    }
                                },
                                "total_discount_set":{
                                    "shop_money":{
                                        "amount":"0.00",
                                        "currency_code":"USD"
                                    },
                                    "presentment_money":{
                                        "amount":"0.00",
                                        "currency_code":"USD"
                                    }
                                },
                                "discount_allocations":[
                                    {
                                        "amount":"3.33",
                                        "discount_application_index":0,
                                        "amount_set":{
                                            "shop_money":{
                                                "amount":"3.33",
                                                "currency_code":"USD"
                                            },
                                            "presentment_money":{
                                                "amount":"3.33",
                                                "currency_code":"USD"
                                            }
                                        }
                                    }
                                ],
                                "duties":[

                                ],
                                "admin_graphql_api_id":"gid://shopify/LineItem/703073504",
                                "tax_lines":[
                                    {
                                        "title":"State Tax",
                                        "price":"3.98",
                                        "rate":0.06,
                                        "price_set":{
                                            "shop_money":{
                                                "amount":"3.98",
                                                "currency_code":"USD"
                                            },
                                            "presentment_money":{
                                                "amount":"3.98",
                                                "currency_code":"USD"
                                            }
                                        }
                                    }
                                ]
                            }
                        },
                        {
                            "id":709875399,
                            "quantity":1,
                            "line_item_id":466157049,
                            "location_id":487838322,
                            "restock_type":"legacy_restock",
                            "subtotal":195.66,
                            "total_tax":3.98,
                            "subtotal_set":{
                                "shop_money":{
                                    "amount":"195.66",
                                    "currency_code":"USD"
                                },
                                "presentment_money":{
                                    "amount":"195.66",
                                    "currency_code":"USD"
                                }
                            },
                            "total_tax_set":{
                                "shop_money":{
                                    "amount":"3.98",
                                    "currency_code":"USD"
                                },
                                "presentment_money":{
                                    "amount":"3.98",
                                    "currency_code":"USD"
                                }
                            },
                            "line_item":{
                                "id":466157049,
                                "variant_id":39072856,
                                "title":"IPod Nano - 8gb",
                                "quantity":1,
                                "sku":"IPOD2008GREEN",
                                "variant_title":"green",
                                "vendor":null,
                                "fulfillment_service":"manual",
                                "product_id":632910392,
                                "requires_shipping":true,
                                "taxable":true,
                                "gift_card":false,
                                "name":"IPod Nano - 8gb - green",
                                "variant_inventory_management":"shopify",
                                "properties":[
                                    {
                                        "name":"Custom Engraving Front",
                                        "value":"Happy Birthday"
                                    },
                                    {
                                        "name":"Custom Engraving Back",
                                        "value":"Merry Christmas"
                                    }
                                ],
                                "product_exists":true,
                                "fulfillable_quantity":1,
                                "grams":200,
                                "price":"199.00",
                                "total_discount":"0.00",
                                "fulfillment_status":null,
                                "price_set":{
                                    "shop_money":{
                                        "amount":"199.00",
                                        "currency_code":"USD"
                                    },
                                    "presentment_money":{
                                        "amount":"199.00",
                                        "currency_code":"USD"
                                    }
                                },
                                "total_discount_set":{
                                    "shop_money":{
                                        "amount":"0.00",
                                        "currency_code":"USD"
                                    },
                                    "presentment_money":{
                                        "amount":"0.00",
                                        "currency_code":"USD"
                                    }
                                },
                                "discount_allocations":[
                                    {
                                        "amount":"3.34",
                                        "discount_application_index":0,
                                        "amount_set":{
                                            "shop_money":{
                                                "amount":"3.34",
                                                "currency_code":"USD"
                                            },
                                            "presentment_money":{
                                                "amount":"3.34",
                                                "currency_code":"USD"
                                            }
                                        }
                                    }
                                ],
                                "duties":[

                                ],
                                "admin_graphql_api_id":"gid://shopify/LineItem/466157049",
                                "tax_lines":[
                                    {
                                        "title":"State Tax",
                                        "price":"3.98",
                                        "rate":0.06,
                                        "price_set":{
                                            "shop_money":{
                                                "amount":"3.98",
                                                "currency_code":"USD"
                                            },
                                            "presentment_money":{
                                                "amount":"3.98",
                                                "currency_code":"USD"
                                            }
                                        }
                                    }
                                ]
                            }
                        }
                    ],
                    "transactions":[
                        {
                            "id":179259969,
                            "order_id":450789469,
                            "kind":"refund",
                            "gateway":"bogus",
                            "status":"success",
                            "message":null,
                            "created_at":"2005-08-05T12:59:12-04:00",
                            "test":false,
                            "authorization":"authorization-key",
                            "location_id":null,
                            "user_id":null,
                            "parent_id":801038806,
                            "processed_at":"2005-08-05T12:59:12-04:00",
                            "device_id":null,
                            "receipt":{

                            },
                            "error_code":null,
                            "source_name":"web",
                            "amount":"209.00",
                            "currency":"USD",
                            "admin_graphql_api_id":"gid://shopify/OrderTransaction/179259969"
                        }
                    ],
                    "order_adjustments":[

                    ]
                }
            ],
            "total_tip_received":"0.0",
            "original_total_duties_set":null,
            "current_total_duties_set":null,
            "admin_graphql_api_id":"gid://shopify/Order/450789469",
            "shipping_lines":[
                {
                    "id":369256396,
                    "title":"Free Shipping",
                    "price":"0.00",
                    "code":"Free Shipping",
                    "source":"shopify",
                    "phone":null,
                    "requested_fulfillment_service_id":null,
                    "delivery_category":null,
                    "carrier_identifier":null,
                    "discounted_price":"0.00",
                    "price_set":{
                        "shop_money":{
                            "amount":"0.00",
                            "currency_code":"USD"
                        },
                        "presentment_money":{
                            "amount":"0.00",
                            "currency_code":"USD"
                        }
                    },
                    "discounted_price_set":{
                        "shop_money":{
                            "amount":"0.00",
                            "currency_code":"USD"
                        },
                        "presentment_money":{
                            "amount":"0.00",
                            "currency_code":"USD"
                        }
                    },
                    "discount_allocations":[

                    ],
                    "tax_lines":[

                    ]
                }
            ],
            "billing_address":{
                "first_name":"Bob",
                "address1":"Chestnut Street 92",
                "phone":"555-625-1199",
                "city":"Louisville",
                "zip":"40202",
                "province":"Kentucky",
                "country":"United States",
                "last_name":"Norman",
                "address2":"",
                "company":null,
                "latitude":45.41634,
                "longitude":-75.6868,
                "name":"Bob Norman",
                "country_code":"US",
                "province_code":"KY"
            },
            "shipping_address":{
                "first_name":"Bob",
                "address1":"Chestnut Street 92",
                "phone":"555-625-1199",
                "city":"Louisville",
                "zip":"40202",
                "province":"Kentucky",
                "country":"United States",
                "last_name":"Norman",
                "address2":"",
                "company":null,
                "latitude":45.41634,
                "longitude":-75.6868,
                "name":"Bob Norman",
                "country_code":"US",
                "province_code":"KY"
            },
            "client_details":{
                "browser_ip":"0.0.0.0",
                "accept_language":null,
                "user_agent":null,
                "session_hash":null,
                "browser_width":null,
                "browser_height":null
            },
            "payment_details":{
                "credit_card_bin":null,
                "avs_result_code":null,
                "cvv_result_code":null,
                "credit_card_number":"•••• •••• •••• 4242",
                "credit_card_company":"Visa"
            },
            "customer":{
                "id":207119551,
                "email":"bob.norman@hostmail.com",
                "accepts_marketing":false,
                "created_at":"2020-10-22T10:31:33-04:00",
                "updated_at":"2020-10-22T10:31:33-04:00",
                "first_name":"Bob",
                "last_name":"Norman",
                "orders_count":1,
                "state":"disabled",
                "total_spent":"199.65",
                "last_order_id":450789469,
                "note":null,
                "verified_email":true,
                "multipass_identifier":null,
                "tax_exempt":false,
                "phone":"+16136120707",
                "tags":"",
                "last_order_name":"#1001",
                "currency":"USD",
                "accepts_marketing_updated_at":"2005-06-12T11:57:11-04:00",
                "marketing_opt_in_level":null,
                "tax_exemptions":[

                ],
                "admin_graphql_api_id":"gid://shopify/Customer/207119551",
                "default_address":{
                    "id":207119551,
                    "customer_id":207119551,
                    "first_name":null,
                    "last_name":null,
                    "company":null,
                    "address1":"Chestnut Street 92",
                    "address2":"",
                    "city":"Louisville",
                    "province":"Kentucky",
                    "country":"United States",
                    "zip":"40202",
                    "phone":"555-625-1199",
                    "name":"",
                    "province_code":"KY",
                    "country_code":"US",
                    "country_name":"United States",
                    "default":true
                }
            }
        }
    ]
}

Retrieve specific orders 检索指定订单

GET /admin/api/unstable/orders.json?ids=1073459962

Retrieve orders that have authorized payments ready to be captured 检索已授权付款的订单

GET /admin/api/unstable/orders.json?financial_status=authorized

Retrieve orders last updated after 2005-07-31 15:57:11 in the EDT timezone 检索订单的最后更新时间为美国东部夏令时间(EDT)时区2005-07-31 15:57:11之后

GET /admin/api/unstable/orders.json?updated_at_min=2005-07-31T15:57:11-04:00

Retrieve all orders but show only certain properties 检索所有订单,但只显示某些属性

GET /admin/api/unstable/orders.json?fields=created_at,id,name,total-price

Retrieve all orders after the specified ID 检索指定 ID 之后的所有订单

GET /admin/api/unstable/orders.json?since_id=123
2、count()
GET  获取/admin/api/unstable/orders/count.json

Retrieves an order count 检索订单计数

字段描述
created_at_min 创建 最小Count orders created after date (format: 2014-04-25T16:15:47-04:00).日期后创建的计数顺序(格式: 2014-04-25T16:15:47-04:00)。
created_at_max 创建最大Count orders created before date (format: 2014-04-25T16:15:47-04:00).在日期前创建的计数顺序(格式: 2014-04-25T16:15:47-04:00)。
updated_at_min 更新时间: 2012年10月12日Count orders last updated after date (format: 2014-04-25T16:15:47-04:00).最后更新日期后(格式: 2014-04-25T16:15:47-04:00)。
updated_at_max 更新时间: 最高时间Count orders last updated before date (format: 2014-04-25T16:15:47-04:00).最后更新日期前(格式: 2014-04-25T16:15:47-04:00)。
status 地位Count orders of a given status.计算给定状态的订单数量。(default: (默认值:open)open: Count open orders. 公开: 数未结订单closed: Count closed orders. 关闭: 计数关闭的命令any: Count orders of any status. 任何: 计算任何状态的订单
financial_status 经济状况Count orders of a given financial status.计算特定财务状况下的订单数量。(default: (默认值:any)authorized: Count authorized orders. 授权: 计数授权命令pending: Count pending orders. 挂起: 计算挂起的命令paid: Count paid orders. 付费: 计算付费订单refunded: Count refunded orders. 退款: 退款数额voided: Count voided orders. 作废: 作废的命令any: Count orders of any financial status. 任何: 清点任何财务状况的订单
fulfillment_status 实现状态Filter orders by their fulfillment status.根据订单的完成情况过滤订单。(default: (默认值:any)shipped: Show orders that have been shipped. Returns orders with fulfillment_status of fulfilled. 发货: 显示已经发货的订单。返回满足 _ 状态的订单partial: Show partially shipped orders. 部分: 显示部分发货订单unshipped: Show orders that have not yet been shipped. Returns orders with fulfillment_status of null. 未发货: 显示尚未发货的订单。返回满足 _ 状态为 null 的订单any: Show orders of any fulfillment status. 任何: 显示任何完成状态的订单unfulfilled: Returns orders with fulfillment_status of null or partial. 未满足: 返回满足 _ 状态为 null 或部分的订单

Count all orders 清点所有的订单

GET /admin/api/unstable/orders/count.json

View Response 查看响应

Count orders that have authorized payments ready to be captured 计算已授权付款准备被捕获的订单

GET /admin/api/unstable/orders/count.json?financial_status=authorized

View Response 查看响应

3、close()
POST  /admin/api/unstable/orders/{order_id}/close.json

Closes an order 关闭一个订单

POST /admin/api/unstable/orders/450789469/close.json

View Response 查看响应

4、open()
POST /admin/api/unstable/orders/{order_id}/open.json

Re-opens a closed order 重新打开一个关闭的订单

POST /admin/api/unstable/orders/450789469/open.json

View Response 查看响应

5、cancel()

POST /admin/api/unstable/orders/{order_id}/cancel.json

Caution 注意

For multi-currency orders, the currency property is required whenever the amount property is provided. For more information, see Migrating to support multiple currencies.

对于多货币订单,只要提供了金额属性,就需要货币属性。有关详细信息,请参阅Migrating to support multiple currencies.。

Cancels an order. Orders that have a fulfillment object can’t be canceled. 取消订单。带有完成目标的订单不能取消

字段描述
amount 金额The amount to refund. If set, Shopify attempts to void or refund the payment, depending on its status. Shopify refunds through a manual gateway in cases where the original transaction was not made in Shopify. Refunds through a manual gateway are recorded as a refund on Shopify, but the customer is not refunded.退款金额。如果设置,Shopify 将根据其状态,尝试取消或退还付款。如果最初的交易不是在 Shopify 完成的,Shopify 可以通过手动网关退款。通过手动网关退款被记录为 Shopify 上的退款,但是客户不退款。
currency 货币The currency of the refund that’s issued when the order is canceled. Required for multi-currency orders whenever the amount property is provided.取消订单时发出的退款货币。在提供金额属性时,多货币订单需要。
restock 补充库存 DEPRECATED 废弃Whether to restock refunded items back to your store’s inventory.是否将退回的物品退回到商店的库存中。(default: (默认值:false)
reason 原因The reason for the order cancellation. Valid values: customer, inventory, fraud, declined, and other.)取消订单的原因。有效值: 客户、库存、欺诈、拒绝和其他。)(default: (默认值:other)
email 电子邮件Whether to send an email to the customer notifying them of the cancellation.是否向客户发送电子邮件通知取消。(default: (默认值:false)
refund 退款The refund transactions to perform. Required for some more complex refund situations. For more information, see the Refund API.要执行的退款交易。需要一些更复杂的退款情况。有关更多信息,请参阅退款 API。

Cancel an order

取消订单

POST /admin/api/unstable/orders/450789469/cancel.json
{
}

View Response 查看响应

Cancel and refund an order using the amount property

使用金额属性取消和退还订单

POST /admin/api/unstable/orders/450789469/cancel.json
{
  "amount": "10.00",
  "currency": "USD"
}

View Response 查看响应

When an order has multiple refundable transactions, refunding an amount less than its net payment without a refund property fails with an error

当一个订单有多个可退还的交易,退款金额低于其净付款额没有退款财产失败与一个错误

POST /admin/api/unstable/orders/450789469/cancel.json
{
  "amount": "109.00",
  "currency": "USD"
}

View Response 查看响应

Cancel and refund an order using the refund property

使用退款属性取消和退还订单

POST /admin/api/unstable/orders/450789469/cancel.json
{
  "refund": {
    "note": "Customer made a mistake",
    "shipping": {
      "full_refund": true
    },
    "refund_line_items": [
      {
        "line_item_id": 466157049,
        "quantity": 1,
        "restock_type": "cancel",
        "location_id": 48752903
      }
    ],
    "transactions": [
      {
        "parent_id": 1072844670,
        "amount": "10.00",
        "kind": "refund",
        "gateway": "bogus"
      },
      {
        "parent_id": 1072844671,
        "amount": "100.00",
        "kind": "refund",
        "gateway": "gift_card"
      }
    ]
  }
}

View Response 查看响应

Canceling an order that has fulfillments fails with an error

取消已完成的订单是失败的,也是错误的

POST /admin/api/unstable/orders/450789469/cancel.json
{
}

View Response 查看响应

unstable()

POST /admin/api/unstable/orders.json

Creates an order. By default, product inventory is not claimed.

创建订单。默认情况下,产品库存不被认领。

When you create an order, you can include the following option parameters in the body of the request:

当你创建一个订单时,你可以在请求的正文中包含以下选项参数:

  • inventory_behaviour
    The behaviour to use when updating inventory. (default: bypass) 库存 _ 行为: 更新库存时使用的行为。(默认: 旁路)
    • bypass: Do not claim inventory. 旁路: 不索赔库存。
    • decrement_ignoring_policy: Ignore the product’s inventory policy and claim inventory. 减量忽略策略: 忽略产品的库存策略和索赔库存。
    • decrement_obeying_policy: Follow the product’s inventory policy and claim inventory, if possible. 遵守库存政策: 如果可能的话,遵守产品的库存政策和索赔库存
  • send_receipt: Whether to send an order confirmation to the customer. Send _ receipt: 是否向客户发送订单确认

Note 注意:

If you’re working on a private app and order confirmations are still being sent to the customer when send_receipt is set to false, then you need to disable the Storefront API from the private app’s page in the Shopify admin.

如果你正在开发一个私有应用程序,当发送收据设置为 false 时,订单确认信息仍然会发送给客户,那么你需要在 Shopify admin 的私有应用程序页面上禁用 Storefront API。

  • send_fulfillment_receipt: Whether to send a shipping confirmation to the customer. 发送 _ 履行 _ 收据: 是否向客户发送送货确认

Note 注意:

If you are including shipping_address or billing_address, make sure to pass both first_name and last_name. Otherwise both these addresses will be ignored.

如果您包含送货地址或者账单地址,请确保同时传递名字和姓氏。否则这两个地址都将被忽略。

If you’re using this endpoint with a trial or Partner development store, then you can create no more than 5 new orders per minute.

如果将此端点用于试用或合作伙伴开发存储,则每分钟不能创建超过5个新订单。

Create a simple order with only a product variant ID

创建一个只有产品变量 ID 的简单订单

POST /admin/api/unstable/orders.json
{
  "order": {
    "line_items": [
      {
        "variant_id": 447654529,
        "quantity": 1
      }
    ]
  }
}

View Response 查看响应

Create a simple order, sending an order confirmation and a shipping confirmation to the customer

创建一个简单的订单,向客户发送订单确认和发货确认

POST /admin/api/unstable/orders.json
{
  "order": {
    "email": "foo@example.com",
    "fulfillment_status": "fulfilled",
    "send_receipt": true,
    "send_fulfillment_receipt": true,
    "line_items": [
      {
        "variant_id": 457924702,
        "quantity": 1
      }
    ]
  }
}

View Response 查看响应

Create a simple order without sending an order receipt or a fulfillment receipt

创建一个简单的订单,而不发送订单收据或履行收据

POST /admin/api/unstable/orders.json
{
  "order": {
    "email": "foo@example.com",
    "fulfillment_status": "fulfilled",
    "line_items": [
      {
        "variant_id": 447654529,
        "quantity": 1
      }
    ]
  }
}

View Response 查看响应

Create a simple order and fulfill it

创建一个简单的订单并完成它

POST /admin/api/unstable/orders.json
{
  "order": {
    "email": "foo@example.com",
    "fulfillment_status": "fulfilled",
    "fulfillments": [
      {
        "location_id": 48752903
      }
    ],
    "line_items": [
      {
        "variant_id": 447654529,
        "quantity": 1
      }
    ]
  }
}

View Response 查看响应

Create a comprehensive order

建立一个全面的订单

POST /admin/api/unstable/orders.json
{
  "order": {
    "line_items": [
      {
        "title": "Big Brown Bear Boots",
        "price": 74.99,
        "grams": "1300",
        "quantity": 3,
        "tax_lines": [
          {
            "price": 13.5,
            "rate": 0.06,
            "title": "State tax"
          }
        ]
      }
    ],
    "transactions": [
      {
        "kind": "sale",
        "status": "success",
        "amount": 238.47
      }
    ],
    "total_tax": 13.5,
    "currency": "EUR"
  }
}

View Response 查看响应

Create an order with tax lines split across taxable line items

创建一个订单,在应税项目之间划分税线

POST /admin/api/unstable/orders.json
{
  "order": {
    "line_items": [
      {
        "title": "Red Leather Coat",
        "price": 129.99,
        "grams": "1700",
        "quantity": 1
      },
      {
        "title": "Blue Suede Shoes",
        "price": 85.95,
        "grams": "750",
        "quantity": 1,
        "taxable": false
      },
      {
        "title": "Raspberry Beret",
        "price": 19.99,
        "grams": "320",
        "quantity": 2
      }
    ],
    "tax_lines": [
      {
        "price": 10.2,
        "rate": 0.06,
        "title": "State tax"
      },
      {
        "price": 4.25,
        "rate": 0.025,
        "title": "County tax"
      }
    ],
    "total_tax": 14.45
  }
}

View Response 查看响应

Creating an order with tax lines both on line items and on the order fails and returns an error

在行项和订单上创建带有赋税行的订单失败并返回错误

POST /admin/api/unstable/orders.json
{
  "order": {
    "line_items": [
      {
        "title": "Clicky Keyboard",
        "price": 99.99,
        "grams": "600",
        "quantity": 1,
        "tax_lines": [
          {
            "price": 1.0,
            "rate": 0.01,
            "title": "Keyboard tax"
          }
        ]
      }
    ],
    "tax_lines": [
      {
        "price": 6.0,
        "rate": 0.06,
        "title": "State tax"
      }
    ]
  }
}

View Response 查看响应

Create a pending order with an existing customer

使用现有客户创建挂起的订单

POST /admin/api/unstable/orders.json
{
  "order": {
    "line_items": [
      {
        "variant_id": 447654529,
        "quantity": 1
      }
    ],
    "customer": {
      "id": 207119551
    },
    "financial_status": "pending"
  }
}

View Response 查看响应

Create a partially paid order with a new customer and addresses

创建一个新客户和地址的部分付费订单

POST /admin/api/unstable/orders.json
{
  "order": {
    "line_items": [
      {
        "variant_id": 447654529,
        "quantity": 1
      }
    ],
    "customer": {
      "first_name": "Paul",
      "last_name": "Norman",
      "email": "paul.norman@example.com"
    },
    "billing_address": {
      "first_name": "John",
      "last_name": "Smith",
      "address1": "123 Fake Street",
      "phone": "555-555-5555",
      "city": "Fakecity",
      "province": "Ontario",
      "country": "Canada",
      "zip": "K2P 1L4"
    },
    "shipping_address": {
      "first_name": "Jane",
      "last_name": "Smith",
      "address1": "123 Fake Street",
      "phone": "777-777-7777",
      "city": "Fakecity",
      "province": "Ontario",
      "country": "Canada",
      "zip": "K2P 1L4"
    },
    "email": "jane@example.com",
    "transactions": [
      {
        "kind": "authorization",
        "status": "success",
        "amount": 50.0
      }
    ],
    "financial_status": "partially_paid"
  }
}

View Response 查看响应

Create an order and apply a discount

创建一个订单并申请折扣

POST /admin/api/unstable/orders.json
{
  "order": {
    "line_items": [
      {
        "variant_id": 447654529,
        "quantity": 1
      }
    ],
    "email": "jane@example.com",
    "phone": "18885551234",
    "billing_address": {
      "first_name": "John",
      "last_name": "Smith",
      "address1": "123 Fake Street",
      "phone": "555-555-5555",
      "city": "Fakecity",
      "province": "Ontario",
      "country": "Canada",
      "zip": "K2P 1L4"
    },
    "shipping_address": {
      "first_name": "Jane",
      "last_name": "Smith",
      "address1": "123 Fake Street",
      "phone": "777-777-7777",
      "city": "Fakecity",
      "province": "Ontario",
      "country": "Canada",
      "zip": "K2P 1L4"
    },
    "transactions": [
      {
        "kind": "sale",
        "status": "success",
        "amount": 50.0
      }
    ],
    "financial_status": "paid",
    "discount_codes": [
      {
        "code": "FAKE30",
        "amount": "9.00",
        "type": "percentage"
      }
    ]
  }
}

View Response 查看响应

PUT
PUT /admin/api/unstable/orders/{order_id}.json

Updates an order 更新订单

Add a note to order

给订单添加注释

PUT /admin/api/unstable/orders/450789469.json
{
  "order": {
    "id": 450789469,
    "note": "Customer contacted us about a custom engraving on this iPod"
  }
}

View Response 查看响应

Add note attributes to an order

向订单添加注释属性

PUT /admin/api/unstable/orders/450789469.json
{
  "order": {
    "id": 450789469,
    "note_attributes": [
      {
        "name": "colour",
        "value": "red"
      }
    ]
  }
}

View Response 查看响应

Change an order’s email address

更改订单的电子邮件地址

PUT /admin/api/unstable/orders/450789469.json
{
  "order": {
    "id": 450789469,
    "email": "a-different@email.com"
  }
}

View Response 查看响应

Change an order’s phone number

更改订单的电话号码

PUT /admin/api/unstable/orders/450789469.json
{
  "order": {
    "id": 450789469,
    "phone": "+15145556677"
  }
}

View Response 查看响应

Change whether the buyer accepts marketing

改变买方是否接受市场营销

PUT /admin/api/unstable/orders/450789469.json
{
  "order": {
    "id": 450789469,
    "buyer_accepts_marketing": true
  }
}

View Response 查看响应

Add a metafield to an order

向订单添加元字段

PUT /admin/api/unstable/orders/450789469.json
{
  "order": {
    "id": 450789469,
    "metafields": [
      {
        "key": "new",
        "value": "newvalue",
        "value_type": "string",
        "namespace": "global"
      }
    ]
  }
}

View Response 查看响应

Update the shipping address of an order

更新订单的送货地址

PUT /admin/api/unstable/orders/450789469.json
{
  "order": {
    "id": 450789469,
    "shipping_address": {
      "address1": "123 Ship Street",
      "city": "Shipsville"
    }
  }
}

View Response 查看响应

Remove the customer from an order

从订单中删除客户

PUT /admin/api/unstable/orders/450789469.json
{
  "order": {
    "id": 450789469,
    "customer": null
  }
}

View Response 查看响应

Update an order’s tags

更新订单的标签

PUT /admin/api/unstable/orders/450789469.json
{
  "order": {
    "id": 450789469,
    "tags": "External, Inbound, Outbound"
  }
}
DELETE
DELETE /admin/api/unstable/orders/{order_id}.json

Deletes an order. Orders that interact with an online gateway can’t be deleted. 删除订单。与联机网关交互的订单无法删除

Delete an order

删除订单

DELETE /admin/api/unstable/orders/450789469.json

View Response 查看响应

Change an order’s phone number

更改订单的电话号码

PUT /admin/api/unstable/orders/450789469.json
{
  "order": {
    "id": 450789469,
    "phone": "+15145556677"
  }
}

View Response 查看响应

Change whether the buyer accepts marketing

改变买方是否接受市场营销

PUT /admin/api/unstable/orders/450789469.json
{
  "order": {
    "id": 450789469,
    "buyer_accepts_marketing": true
  }
}

View Response 查看响应

Add a metafield to an order

向订单添加元字段

PUT /admin/api/unstable/orders/450789469.json
{
  "order": {
    "id": 450789469,
    "metafields": [
      {
        "key": "new",
        "value": "newvalue",
        "value_type": "string",
        "namespace": "global"
      }
    ]
  }
}

View Response 查看响应

Update the shipping address of an order

更新订单的送货地址

PUT /admin/api/unstable/orders/450789469.json
{
  "order": {
    "id": 450789469,
    "shipping_address": {
      "address1": "123 Ship Street",
      "city": "Shipsville"
    }
  }
}

View Response 查看响应

Remove the customer from an order

从订单中删除客户

PUT /admin/api/unstable/orders/450789469.json
{
  "order": {
    "id": 450789469,
    "customer": null
  }
}

View Response 查看响应

Update an order’s tags

更新订单的标签

PUT /admin/api/unstable/orders/450789469.json
{
  "order": {
    "id": 450789469,
    "tags": "External, Inbound, Outbound"
  }
}
DELETE
DELETE /admin/api/unstable/orders/{order_id}.json

Deletes an order. Orders that interact with an online gateway can’t be deleted. 删除订单。与联机网关交互的订单无法删除

Delete an order

删除订单

DELETE /admin/api/unstable/orders/450789469.json

View Response 查看响应

  • 4
    点赞
  • 33
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
Shopify 是一个非常流行的电子商务平台,拥有强大的后台管理功能,允许用户通过 API 与该平台交互,从而实现自动化商务流程的目的。PHP 作为一种开源的服务器脚本语言,被广泛应用于 Web 开发领域,在与 Shopify 后台 API 对接时也是一种常用的工具。 要对接 Shopify 后台 API,首先需要创建一个 Shopify 店铺账户,并获取到 API 密钥和密码。这些信息可以在 Shopify 店铺的后台管理页面中找到。接下来,需要在 PHP 代码中使用所获取到的 API 密钥和密码,调用 Shopify 后台 API 提供的各种接口,实现与该平台的交互。 在 PHP 代码中使用 Shopify 后台 API 时,需要使用特定的 API 客户端库,例如 Shopify PHP API 或者 PHP Shopify API。这些客户端库已经封装了与 Shopify 后台 API 交互的底层实现细节,使得开发人员可以更加方便地调用各种接口。 一些常见的 Shopify 后台 API 接口包括:获取订单、创建订单、更新订单、创建产品、更新产品、创建顾客、获取顾客等。通过这些接口,开发人员可以实现各种商务操作,例如自动化下单、库存管理、支付处理等。 当然,与任何 API 对接一样,与 Shopify 后台 API 的对接也需要注意一些细节。例如,需要注意 API 调用频率的限制,避免因为过度频繁的调用而被认为是恶意攻击。同时,还需要根据具体的业务需求,选择合适的 API 接口,避免不必要的 API 调用,提高系统的响应速度和安全性。 总之,PHP 对接 Shopify 后台 API 的过程既是技术上的挑战,也是商务上的机遇。只有通过精确的技术实现和深入的商务分析,才能充分发挥 Shopify 平台所提供的各种优势,为用户提供更好的电子商务服务。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值