wordpress之woocommer手册---customers顾客篇

Customers

This section lists all API that can be used to create, edit or otherwise manipulate customers.

Customers Properties

AttributeTypeDescription
idintegerCustomer ID (user ID) read-only
created_atstringUTC DateTime when the customer was created read-only
emailstringCustomer email address mandatory
first_namestringCustomer first name
last_namestringCustomer last name
usernamestringCustomer username, can be generated automatically from the customer’s email addrees if the option woocommerce_registration_generate_username is equal to yes cannot be changed
passwordstringCustomer password, can be generated automatically with wp_generate_password() if the “Automatically generate customer password” option is enabled, check the index meta for generate_password write-only
last_order_idintegerLast order ID read-only
last_order_datestringUTC DateTime of the customer last order read-only
orders_countintegerQuantity of orders that the customer have read-only
total_spentintegerTotal amount spent read-only
avatar_urlstringGravatar URL
billing_addressarrayList of Billing Address fields. See Billing Address Properties
shipping_addressarrayList of Shipping Address fields. See Shipping Address Properties

Billing Address Properties

AttributeTypeDescription
first_namestringFirst name
last_namestringLast name
companystringCompany name
address_1stringAddress line 1
address_2stringAddress line 2
citystringCity name
statestringISO code or name of the state, province or district
postcodestringPostal code
countrystringISO code of the country
emailstringEmail address
phonestringPhone

Shipping Address Properties

AttributeTypeDescription
first_namestringFirst name
last_namestringLast name
companystringCompany name
address_1stringAddress line 1
address_2stringAddress line 2
citystringCity name
statestringISO code or name of the state, province or district
postcodestringPostal code
countrystringISO code of the country

Create A Customer

This API helps you to create a new customer.

HTTP Request

POST
/wc-api/v3/customers
curl -X POST https://example.com/wc-api/v3/customers \
	-u consumer_key:consumer_secret \
	-H "Content-Type: application/json" \
	-d '{
  "customer": {
    "email": "john.doe@example.com",
    "first_name": "John",
    "last_name": "Doe",
    "username": "john.doe",
    "billing_address": {
      "first_name": "John",
      "last_name": "Doe",
      "company": "",
      "address_1": "969 Market",
      "address_2": "",
      "city": "San Francisco",
      "state": "CA",
      "postcode": "94103",
      "country": "US",
      "email": "john.doe@example.com",
      "phone": "(555) 555-5555"
    },
    "shipping_address": {
      "first_name": "John",
      "last_name": "Doe",
      "company": "",
      "address_1": "969 Market",
      "address_2": "",
      "city": "San Francisco",
      "state": "CA",
      "postcode": "94103",
      "country": "US"
    }
  }
}'
var data = {
  customer: {
    email: 'john.doe@example.com',
    first_name: 'John',
    last_name: 'Doe',
    username: 'john.doe',
    billing_address: {
      first_name: 'John',
      last_name: 'Doe',
      company: '',
      address_1: '969 Market',
      address_2: '',
      city: 'San Francisco',
      state: 'CA',
      postcode: '94103',
      country: 'US',
      email: 'john.doe@example.com',
      phone: '(555) 555-5555'
    },
    shipping_address: {
      first_name: 'John',
      last_name: 'Doe',
      company: '',
      address_1: '969 Market',
      address_2: '',
      city: 'San Francisco',
      state: 'CA',
      postcode: '94103',
      country: 'US'
    }
  }
};

WooCommerce.post('customers', data, function(err, data, res) {
  console.log(res);
});
data = {
    "customer": {
        "email": "john.doe@example.com",
        "first_name": "John",
        "last_name": "Doe",
        "username": "john.doe",
        "billing_address": {
            "first_name": "John",
            "last_name": "Doe",
            "company": "",
            "address_1": "969 Market",
            "address_2": "",
            "city": "San Francisco",
            "state": "CA",
            "postcode": "94103",
            "country": "US",
            "email": "john.doe@example.com",
            "phone": "(555) 555-5555"
        },
        "shipping_address": {
            "first_name": "John",
            "last_name": "Doe",
            "company": "",
            "address_1": "969 Market",
            "address_2": "",
            "city": "San Francisco",
            "state": "CA",
            "postcode": "94103",
            "country": "US"
        }
    }
}

print(wcapi.post("customers", data).json())
data = {
  customer: {
    email: "john.doe@example.com",
    first_name: "John",
    last_name: "Doe",
    username: "john.doe",
    billing_address: {
      first_name: "John",
      last_name: "Doe",
      company: "",
      address_1: "969 Market",
      address_2: "",
      city: "San Francisco",
      state: "CA",
      postcode: "94103",
      country: "US",
      email: "john.doe@example.com",
      phone: "(555) 555-5555"
    },
    shipping_address: {
      first_name: "John",
      last_name: "Doe",
      company: "",
      address_1: "969 Market",
      address_2: "",
      city: "San Francisco",
      state: "CA",
      postcode: "94103",
      country: "US"
    }
  }
}

woocommerce.post("customers", data).parsed_response

JSON response example:

{
  "customer": {
    "id": 2,
    "created_at": "2015-01-05T18:34:19Z",
    "email": "john.doe@example.com",
    "first_name": "John",
    "last_name": "Doe",
    "username": "john.doe",
    "last_order_id": null,
    "last_order_date": null,
    "orders_count": 0,
    "total_spent": "0.00",
    "avatar_url": "https://secure.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=96",
    "billing_address": {
      "first_name": "John",
      "last_name": "Doe",
      "company": "",
      "address_1": "969 Market",
      "address_2": "",
      "city": "San Francisco",
      "state": "CA",
      "postcode": "94103",
      "country": "US",
      "email": "john.doe@example.com",
      "phone": "(555) 555-5555"
    },
    "shipping_address": {
      "first_name": "John",
      "last_name": "Doe",
      "company": "",
      "address_1": "969 Market",
      "address_2": "",
      "city": "San Francisco",
      "state": "CA",
      "postcode": "94103",
      "country": "US"
    }
  }
}

View A Customer

This API lets you retrieve and view a specific customer by ID or email.

HTTP Request

GET
/wc-api/v3/customers/<id>
GET
/wc-api/v3/customers/email/<email>
curl https://example.com/wc-api/v3/customers/2 \
	-u consumer_key:consumer_secret
WooCommerce.get('customers/2', function(err, data, res) {
  console.log(res);
});
print(wcapi.get("customers/2").json())
woocommerce.get("customers/2").parsed_response

JSON response example:

{
  "customer": {
    "id": 2,
    "created_at": "2015-01-05T18:34:19Z",
    "email": "john.doe@example.com",
    "first_name": "John",
    "last_name": "Doe",
    "username": "john.doe",
    "last_order_id": null,
    "last_order_date": null,
    "orders_count": 0,
    "total_spent": "0.00",
    "avatar_url": "https://secure.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=96",
    "billing_address": {
      "first_name": "John",
      "last_name": "Doe",
      "company": "",
      "address_1": "969 Market",
      "address_2": "",
      "city": "San Francisco",
      "state": "CA",
      "postcode": "94103",
      "country": "US",
      "email": "john.doe@example.com",
      "phone": "(555) 555-5555"
    },
    "shipping_address": {
      "first_name": "John",
      "last_name": "Doe",
      "company": "",
      "address_1": "969 Market",
      "address_2": "",
      "city": "San Francisco",
      "state": "CA",
      "postcode": "94103",
      "country": "US"
    }
  }
}

View List Of Customers

This API helps you to view all the customers.

HTTP Request

GET
/wc-api/v3/customers
curl https://example.com/wc-api/v3/customers \
	-u consumer_key:consumer_secret
WooCommerce.get('customers', function(err, data, res) {
  console.log(res);
});
print(wcapi.get("customers").json())
woocommerce.get("customers").parsed_response

JSON response example:

{
  "customers": [
    {
      "id": 2,
      "created_at": "2015-01-05T18:34:19Z",
      "email": "john.doe@example.com",
      "first_name": "John",
      "last_name": "Doe",
      "username": "john.doe",
      "last_order_id": 123,
      "last_order_date": "2015-01-14T16:47:30Z",
      "orders_count": 10,
      "total_spent": "1034.58",
      "avatar_url": "https://secure.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=96",
      "billing_address": {
        "first_name": "John",
        "last_name": "Doe",
        "company": "",
        "address_1": "969 Market",
        "address_2": "",
        "city": "San Francisco",
        "state": "CA",
        "postcode": "94103",
        "country": "US",
        "email": "john.doe@example.com",
        "phone": "(555) 555-5555"
      },
      "shipping_address": {
        "first_name": "John",
        "last_name": "Doe",
        "company": "",
        "address_1": "969 Market",
        "address_2": "",
        "city": "San Francisco",
        "state": "CA",
        "postcode": "94103",
        "country": "US"
      }
    },
    {
      "id": 3,
      "created_at": "2015-01-10T14:25:39Z",
      "email": "joao.silva@example.com",
      "first_name": "João",
      "last_name": "Silva",
      "username": "joao.silva",
      "last_order_id": 120,
      "last_order_date": "2015-01-10T14:26:30Z",
      "orders_count": 1,
      "total_spent": "429.00",
      "avatar_url": "https://secure.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=96",
      "billing_address": {
        "first_name": "João",
        "last_name": "Silva",
        "company": "",
        "address_1": "Av. Brasil, 432",
        "address_2": "",
        "city": "Rio de Janeiro",
        "state": "RJ",
        "postcode": "12345-000",
        "country": "BR",
        "email": "joao.silva@example.com",
        "phone": "(55) 5555-5555"
      },
      "shipping_address": {
        "first_name": "João",
        "last_name": "Silva",
        "company": "",
        "address_1": "Av. Brasil, 432",
        "address_2": "",
        "city": "Rio de Janeiro",
        "state": "RJ",
        "postcode": "12345-000",
        "country": "BR"
      }
    }
  ]
}

Available Filters

FilterTypeDescription
rolestringCustomers by status. eg: customer or subscriber

Update A Customer

This API lets you make changes to a customer.

HTTP Request

PUT
/wc-api/v3/customers/<id>
curl -X PUT https://example.com/wc-api/v3/customers/2 \
	-u consumer_key:consumer_secret \
	-H "Content-Type: application/json" \
	-d '{
  "customer": {
    "first_name": "James",
    "billing_address": {
      "first_name": "James"
    },
    "shipping_address": {
      "first_name": "James"
    }
  }
}'
var data = {
  customer: {
    first_name: 'James',
    billing_address: {
      first_name: 'James'
    },
    shipping_address: {
      first_name: 'James'
    }
  }
};

WooCommerce.put('customers/2', data, function(err, data, res) {
  console.log(res);
});
data = {
    "customer": {
        "first_name": "James",
        "billing_address": {
            "first_name": "James"
        },
        "shipping_address": {
            "first_name": "James"
        }
    }
}

print(wcapi.put("customers/2", data).json())
data = {
  customer: {
    first_name: "James",
    billing_address: {
      first_name: "James"
    },
    shipping_address: {
      first_name: "James"
    }
  }
}

woocommerce.put("customers/2", data).parsed_response

JSON response example:

{
  "customer": {
    "id": 2,
    "created_at": "2015-01-05T18:34:19Z",
    "email": "john.doe@example.com",
    "first_name": "James",
    "last_name": "Doe",
    "username": "john.doe",
    "last_order_id": null,
    "last_order_date": null,
    "orders_count": 0,
    "total_spent": "0.00",
    "avatar_url": "https://secure.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=96",
    "billing_address": {
      "first_name": "John",
      "last_name": "Doe",
      "company": "",
      "address_1": "969 Market",
      "address_2": "",
      "city": "San Francisco",
      "state": "CA",
      "postcode": "94103",
      "country": "US",
      "email": "john.doe@example.com",
      "phone": "(555) 555-5555"
    },
    "shipping_address": {
      "first_name": "John",
      "last_name": "Doe",
      "company": "",
      "address_1": "969 Market",
      "address_2": "",
      "city": "San Francisco",
      "state": "CA",
      "postcode": "94103",
      "country": "US"
    }
  }
}

Create/Update Multiple Customers

This API helps you to bulk create/update multiple customers.

To update is necessary to send objects containing IDs and to create new not just send the ID.

HTTP Request

POST
/wc-api/v3/customers/bulk
curl -X PUT https://example.com/wc-api/v3/customers/bulk \
	-u consumer_key:consumer_secret \
	-H "Content-Type: application/json" \
	-d '{
  "customers": [
    {
      "email": "john.doe2@example.com",
      "first_name": "John",
      "last_name": "Doe",
      "username": "john.doe2",
      "billing_address": {
        "first_name": "John",
        "last_name": "Doe",
        "company": "",
        "address_1": "969 Market",
        "address_2": "",
        "city": "San Francisco",
        "state": "CA",
        "postcode": "94103",
        "country": "US",
        "email": "john.doe@example.com",
        "phone": "(555) 555-5555"
      },
      "shipping_address": {
        "first_name": "John",
        "last_name": "Doe",
        "company": "",
        "address_1": "969 Market",
        "address_2": "",
        "city": "San Francisco",
        "state": "CA",
        "postcode": "94103",
        "country": "US"
      }
    },
    {
      "email": "joao.silva2@example.com",
      "first_name": "João",
      "last_name": "Silva",
      "username": "joao.silva2",
      "billing_address": {
        "first_name": "João",
        "last_name": "Silva",
        "company": "",
        "address_1": "Av. Brasil, 432",
        "address_2": "",
        "city": "Rio de Janeiro",
        "state": "RJ",
        "postcode": "12345-000",
        "country": "BR",
        "email": "joao.silva@example.com",
        "phone": "(55) 5555-5555"
      },
      "shipping_address": {
        "first_name": "João",
        "last_name": "Silva",
        "company": "",
        "address_1": "Av. Brasil, 432",
        "address_2": "",
        "city": "Rio de Janeiro",
        "state": "RJ",
        "postcode": "12345-000",
        "country": "BR"
      }
    }
  ]
}'
var data = {
  customers: [
    {
      email: "john.doe2@example.com",
      first_name: "John",
      last_name: "Doe",
      username: "john.doe2",
      billing_address: {
        first_name: "John",
        last_name: "Doe",
        company: "",
        address_1: "969 Market",
        address_2: "",
        city: "San Francisco",
        state: "CA",
        postcode: "94103",
        country: "US",
        email: "john.doe@example.com",
        phone: "(555) 555-5555"
      },
      shipping_address: {
        first_name: "John",
        last_name: "Doe",
        company: "",
        address_1: "969 Market",
        address_2: "",
        city: "San Francisco",
        state: "CA",
        postcode: "94103",
        country: "US"
      }
    },
    {
      email: "joao.silva2@example.com",
      first_name: "João",
      last_name: "Silva",
      username: "joao.silva2",
      billing_address: {
        first_name: "João",
        last_name: "Silva",
        company: "",
        address_1: "Av. Brasil, 432",
        address_2: "",
        city: "Rio de Janeiro",
        state: "RJ",
        postcode: "12345-000",
        country: "BR",
        email: "joao.silva@example.com",
        phone: "(55) 5555-5555"
      },
      shipping_address: {
        first_name: "João",
        last_name: "Silva",
        company: "",
        address_1: "Av. Brasil, 432",
        address_2: "",
        city: "Rio de Janeiro",
        state: "RJ",
        postcode: "12345-000",
        country: "BR"
      }
    }
  ]
};

WooCommerce.put('customers/bulk', data, function(err, data, res) {
  console.log(res);
});
data = {
    "customers": [
        {
            "email": "john.doe2@example.com",
            "first_name": "John",
            "last_name": "Doe",
            "username": "john.doe2",
            "billing_address": {
                "first_name": "John",
                "last_name": "Doe",
                "company": "",
                "address_1": "969 Market",
                "address_2": "",
                "city": "San Francisco",
                "state": "CA",
                "postcode": "94103",
                "country": "US",
                "email": "john.doe@example.com",
                "phone": "(555) 555-5555"
            },
            "shipping_address": {
                "first_name": "John",
                "last_name": "Doe",
                "company": "",
                "address_1": "969 Market",
                "address_2": "",
                "city": "San Francisco",
                "state": "CA",
                "postcode": "94103",
                "country": "US"
            }
        },
        {
            "email": "joao.silva2@example.com",
            "first_name": "João",
            "last_name": "Silva",
            "username": "joao.silva2",
            "billing_address": {
                "first_name": "João",
                "last_name": "Silva",
                "company": "",
                "address_1": "Av. Brasil, 432",
                "address_2": "",
                "city": "Rio de Janeiro",
                "state": "RJ",
                "postcode": "12345-000",
                "country": "BR",
                "email": "joao.silva@example.com",
                "phone": "(55) 5555-5555"
            },
            "shipping_address": {
                "first_name": "João",
                "last_name": "Silva",
                "company": "",
                "address_1": "Av. Brasil, 432",
                "address_2": "",
                "city": "Rio de Janeiro",
                "state": "RJ",
                "postcode": "12345-000",
                "country": "BR"
            }
        }
    ]
}

print(wcapi.put("customers/bulk", data).json())
data = {
  customers: [
    {
      email: "john.doe2@example.com",
      first_name: "John",
      last_name: "Doe",
      username: "john.doe2",
      billing_address: {
        first_name: "John",
        last_name: "Doe",
        company: "",
        address_1: "969 Market",
        address_2: "",
        city: "San Francisco",
        state: "CA",
        postcode: "94103",
        country: "US",
        email: "john.doe@example.com",
        phone: "(555) 555-5555"
      },
      shipping_address: {
        first_name: "John",
        last_name: "Doe",
        company: "",
        address_1: "969 Market",
        address_2: "",
        city: "San Francisco",
        state: "CA",
        postcode: "94103",
        country: "US"
      }
    },
    {
      email: "joao.silva2@example.com",
      first_name: "João",
      last_name: "Silva",
      username: "joao.silva2",
      billing_address: {
        first_name: "João",
        last_name: "Silva",
        company: "",
        address_1: "Av. Brasil, 432",
        address_2: "",
        city: "Rio de Janeiro",
        state: "RJ",
        postcode: "12345-000",
        country: "BR",
        email: "joao.silva@example.com",
        phone: "(55) 5555-5555"
      },
      shipping_address: {
        first_name: "João",
        last_name: "Silva",
        company: "",
        address_1: "Av. Brasil, 432",
        address_2: "",
        city: "Rio de Janeiro",
        state: "RJ",
        postcode: "12345-000",
        country: "BR"
      }
    }
  ]
}

woocommerce.put("customers/bulk", data).parsed_response

JSON response example:

{
  "customers": [
    {
      "id": 4,
      "created_at": "2015-07-31T14:20:46Z",
      "email": "john.doe2@example.com",
      "first_name": "John",
      "last_name": "Doe",
      "username": "john.doe2",
      "last_order_id": null,
      "last_order_date": null,
      "orders_count": 0,
      "total_spent": "0.00",
      "avatar_url": "https://secure.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=96",
      "billing_address": {
        "first_name": "John",
        "last_name": "Doe",
        "company": "",
        "address_1": "969 Market",
        "address_2": "",
        "city": "San Francisco",
        "state": "CA",
        "postcode": "94103",
        "country": "US",
        "email": "john.doe@example.com",
        "phone": "(555) 555-5555"
      },
      "shipping_address": {
        "first_name": "John",
        "last_name": "Doe",
        "company": "",
        "address_1": "969 Market",
        "address_2": "",
        "city": "San Francisco",
        "state": "CA",
        "postcode": "94103",
        "country": "US"
      }
    },
    {
      "id": 5,
      "created_at": "2015-07-31T14:20:46Z",
      "email": "joao.silva2@example.com",
      "first_name": "João",
      "last_name": "Silva",
      "username": "joao.silva2",
      "last_order_id": null,
      "last_order_date": null,
      "orders_count": 0,
      "total_spent": "0.00",
      "avatar_url": "https://secure.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=96",
      "billing_address": {
        "first_name": "João",
        "last_name": "Silva",
        "company": "",
        "address_1": "Av. Brasil, 432",
        "address_2": "",
        "city": "Rio de Janeiro",
        "state": "RJ",
        "postcode": "12345-000",
        "country": "BR",
        "email": "joao.silva@example.com",
        "phone": "(55) 5555-5555"
      },
      "shipping_address": {
        "first_name": "João",
        "last_name": "Silva",
        "company": "",
        "address_1": "Av. Brasil, 432",
        "address_2": "",
        "city": "Rio de Janeiro",
        "state": "RJ",
        "postcode": "12345-000",
        "country": "BR"
      }
    }
  ]
}

Delete A Customer

This API helps you delete a customer.

HTTP Request

DELETE
/wc-api/v3/customers/<id>
curl -X DELETE https://example.com/wc-api/v3/customers/2 \
	-u consumer_key:consumer_secret
WooCommerce.delete('customers/2', function(err, data, res) {
  console.log(res);
});
print(wcapi.delete("customers/2").json())
woocommerce.delete("customers/2").parsed_response

JSON response example:

{
  "message": "Permanently deleted customer"
}

View Customer Orders

This API lets you retrieve the customers orders.

HTTP Request

GET
/wc-api/v3/customers/<id>/orders
curl https://example.com/wc-api/v3/customers/2/orders \
	-u consumer_key:consumer_secret
WooCommerce.get('customers/2/orders', function(err, data, res) {
  console.log(res);
});
print(wcapi.get("customers/2/orders").json())
woocommerce.get("customers/2/orders").parsed_response

JSON response example:

{
  "orders": [
    {
      "id": 531,
      "order_number": 531,
      "created_at": "2015-01-21T12:02:13Z",
      "updated_at": "2015-01-21T12:02:13Z",
      "completed_at": "2015-01-21T12:02:13Z",
      "status": "on-hold",
      "currency": "USD",
      "total": "30.00",
      "subtotal": "20.00",
      "total_line_items_quantity": 1,
      "total_tax": "0.00",
      "total_shipping": "10.00",
      "cart_tax": "0.00",
      "shipping_tax": "0.00",
      "total_discount": "0.00",
      "shipping_methods": "Flat Rate",
      "payment_details": {
        "method_id": "bacs",
        "method_title": "Direct Bank Transfer",
        "paid": false
      },
      "billing_address": {
        "first_name": "John",
        "last_name": "Doe",
        "company": "",
        "address_1": "969 Market",
        "address_2": "",
        "city": "San Francisco",
        "state": "CA",
        "postcode": "94103",
        "country": "US",
        "email": "john.doe@example.com",
        "phone": "(555) 555-5555"
      },
      "shipping_address": {
        "first_name": "John",
        "last_name": "Doe",
        "company": "",
        "address_1": "969 Market",
        "address_2": "",
        "city": "San Francisco",
        "state": "CA",
        "postcode": "94103",
        "country": "US"
      },
      "note": "",
      "customer_ip": "127.0.0.1",
      "customer_user_agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0",
      "customer_id": 2,
      "view_order_url": "https://example.com/my-account/view-order/531",
      "line_items": [
        {
          "id": 417,
          "subtotal": "20.00",
          "subtotal_tax": "0.00",
          "total": "20.00",
          "total_tax": "0.00",
          "price": "20.00",
          "quantity": 1,
          "tax_class": null,
          "name": "Premium Quality",
          "product_id": 19,
          "sku": "",
          "meta": []
        }
      ],
      "shipping_lines": [
        {
          "id": 418,
          "method_id": "flat_rate",
          "method_title": "Flat Rate",
          "total": "10.00"
        }
      ],
      "tax_lines": [],
      "fee_lines": [],
      "coupon_lines": [],
      "customer": {
        "id": 2,
        "created_at": "2014-11-19T18:34:19Z",
        "email": "john.doe@example.com",
        "first_name": "",
        "last_name": "",
        "username": "john.doe",
        "last_order_id": "531",
        "last_order_date": "2015-01-21T12:02:13Z",
        "orders_count": 1,
        "total_spent": "0.00",
        "avatar_url": "https://secure.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=96",
        "billing_address": {
          "first_name": "John",
          "last_name": "Doe",
          "company": "",
          "address_1": "969 Market",
          "address_2": "",
          "city": "San Francisco",
          "state": "CA",
          "postcode": "94103",
          "country": "US",
          "email": "john.doe@example.com",
          "phone": "(555) 555-5555"
        },
        "shipping_address": {
          "first_name": "John",
          "last_name": "Doe",
          "company": "",
          "address_1": "969 Market",
          "address_2": "",
          "city": "San Francisco",
          "state": "CA",
          "postcode": "94103",
          "country": "US"
        }
      }
    }
  ]
}

View Customer Downloads

This API lets you retrieve the customers downloads.

HTTP Request

GET
/wc-api/v3/customers/<id>/downloads
curl https://example.com/wc-api/v3/customers/2/downloads \
	-u consumer_key:consumer_secret
WooCommerce.get('customers/2/downloads', function(err, data, res) {
  console.log(res);
});
print(wcapi.get("customers/2/downloads").json())
woocommerce.get("customers/2/downloads").parsed_response

JSON response example:

{
  "downloads": [
    {
      "download_url": "https://example.com/?download_file=96&order=wc_order_9999999999999&email=john.doe@example.com&key=99999999999999999999999999999999",
      "download_id": "99999999999999999999999999999999",
      "product_id": 96,
      "download_name": "Woo Album #4 &ndash; Woo Album",
      "order_id": 532,
      "order_key": "wc_order_9999999999999",
      "downloads_remaining": "5",
      "access_expires": null,
      "file": {
        "name": "Woo Album",
        "file": "http://example.com/wp-content/uploads/woocommerce_uploads/2015/01/album.zip"
      }
    }
  ]
}

Customer Downloads Properties

AttributeTypeDescription
download_urlstringDownload file URL
download_idstringDownload ID
product_idintegerDownloadable product ID
download_namestringDownloadable file name
order_idintegerOrder ID
order_keystringOrder Key
downloads_remainingstringAmount of downloads remaining. An empty string means that is “Unlimited”
access_expiresstringUTC DateTime when the download access expires. null means “Never”
filearrayList for downloadable files, each one have a name (file name) and file (file URL) attribute

View Customers Count

This API lets you retrieve a count of all customers.

HTTP Request

GET
/wc-api/v3/customers/count
curl https://example.com/wc-api/v3/customers/count \
	-u consumer_key:consumer_secret
WooCommerce.get('customers/count', function(err, data, res) {
  console.log(res);
});
print(wcapi.get("customers/count").json())
woocommerce.get("customers/count").parsed_response

JSON response example:

{
  "count": 10
}

Available Filters

FilterTypeDescription
rolestringCustomers by status. eg: customer or subscriber
posted @ 2022-04-02 09:46  coderwcb  阅读(11)  评论(0)    收藏  举报