Shopify + Python 库:如何创建新的送货地址

Shopify + Python library: how to create new shipping address

我在使用 Python API 添加新送货地址时遇到问题。

让我们把授权部分放在一边,假设我有 customer_id.

我找不到如何放置正确的代码行来实现这个目标。 我搜索了 shopify 测试文件夹,但在那里找不到这样的例子。

有人能给我指出正确的方向吗?

虽然目前还没有 CustomerAddress 资源在官方 python Shopify API 客户端中实现,但您可以将地址信息直接附加到 addresses 属性中Customer 资源作为解决方法:

customer_id = 1234567890

new_address = {
    "address1": "123 Main Street",
    "address2": "#5",
    "city": "New York",
    "company": "",
    "country": "United States",
    "name": "John Smith",
    "phone": "",
    "province": "New York",
    "zip": "10001"
 }

customer = shopify.Customer.find(customer_id)
customer.addresses.append(new_address)
customer.save()