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

Customers

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

Customers Properties

Attribute Type Description
id integer Customer ID (user ID) read-only
created_at string UTC DateTime when the customer was created read-only
email string Customer email address mandatory
first_name string Customer first name
last_name string Customer last name
username string Customer 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
password string Customer 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_id integer Last order ID read-only
last_order_date string UTC DateTime of the customer last order read-only
orders_count integer Quantity of orders that the customer have read-only
total_spent integer Total amount spent read-only
avatar_url string Gravatar URL
billing_address array List of Billing Address fields. See Billing Address Properties
shipping_address array List of Shipping Address fields. See Shipping Address Properties

Billing Address Properties

Attribute Type Description
first_name string First name
last_name string Last name
company string Company name
address_1 string Address line 1
address_2 string Address line 2
city string City name
state string ISO code or name of the state, province or district
postcode string Postal code
country string ISO code of the country
email string Email address
phone string Phone

Shipping Address Properties

Attribute Type Description
first_name string First name
last_name string Last name
company string Company name
address_1 string Address line 1
address_2 string Address line 2
city string City name
state string ISO code or name of the state, province or district
postcode string Postal code
country string ISO 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": "[email protected]",
    "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": "[email protected]",
      "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: '[email protected]',
    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: '[email protected]',
      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": "[email protected]",
        "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": "[email protected]",
            "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: "[email protected]",
    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: "[email protected]",
      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": "[email protected]",
    "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": "[email protected]",
      "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": "[email protected]",
    "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": "[email protected]",
      "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": "[email protected]",
      "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": "[email protected]",
        "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": "[email protected]",
      "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": "[email protected]",
        "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

Filter Type Description
role string Customers 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": "[email protected]",
    "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": "[email protected]",
      "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": "[email protected]",
      "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": "[email protected]",
        "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": "[email protected]",
      "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": "[email protected]",
        "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: "[email protected]",
      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: "[email protected]",
        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: "[email protected]",
      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: "[email protected]",
        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": "[email protected]",
            "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": "[email protected]",
                "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": "[email protected]",
            "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": "[email protected]",
                "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: "[email protected]",
      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: "[email protected]",
        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: "[email protected]",
      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: "[email protected]",
        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": "[email protected]",
      "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": "[email protected]",
        "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": "[email protected]",
      "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": "[email protected]",
        "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": "[email protected]",
        "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": "[email protected]",
        "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": "[email protected]",
          "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 protected]&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

Attribute Type Description
download_url string Download file URL
download_id string Download ID
product_id integer Downloadable product ID
download_name string Downloadable file name
order_id integer Order ID
order_key string Order Key
downloads_remaining string Amount of downloads remaining. An empty string means that is “Unlimited”
access_expires string UTC DateTime when the download access expires. null means “Never”
file array List 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

Filter Type Description
role string Customers by status. eg: customer or subscriber

猜你喜欢

转载自blog.csdn.net/weixin_44797182/article/details/114962636