Ad

Shopify + Python Library: How To Create New Shipping Address

- 1 answer

I'm having troubles adding a new shipping address by using the Python API.

Let's put aside the auth part and assume I have the customer_id.

I couldn't find how to put the correct lines of code to achieve this goal. I've searched the shopify tests folder but couldn't find such example there.

Can someone point me to the right direction?

Ad

Answer

While there is currently no CustomerAddress resource implemented into the official python Shopify API client, you can append the address information directly onto the addresses attribute of the Customer resource as a work-around:

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()
Ad
source: stackoverflow.com
Ad