首页 > 解决方案 > 使用 WooCommerce API 创建新客户需要密码确认

问题描述

发送此 POST 数据时

{
  "email": "john.doe@example.com",
  "first_name": "John",
  "last_name": "Doe",
  "username": "john.doe",
  "password": "Hashem123123@@@",
  "billing": {
    "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": {
    "first_name": "John",
    "last_name": "Doe",
    "company": "",
    "address_1": "969 Market",
    "address_2": "",
    "city": "San Francisco",
    "state": "CA",
    "postcode": "94103",
    "country": "US"
  }
}

使用基本身份验证到https://example.com/wp-json/wc/v3/customers 。我有以下回应

{
    "code": "error_confirm_password_empty",
    "message": "Invalid confirmation password",
    "data": {
        "status": 400
    }
}

注意: 此注册应该提交给管理员进行批准。也许这个终点是直接注册,还有另一个终点是提交注册以供批准(?)我检查了 WooCommerce文档,似乎没有任何类似的东西。

标签: phpwordpressrestwoocommercewoocommerce-rest-api

解决方案


您可以将以下项目与现有数组一起添加。

{
    "email": "john.doe@example.com",
    "first_name": "John",
    "last_name": "Doe",
    "username": "john.doe",
    "password": "Hashem123123@@@",
    "confirm_password": "Hashem123123@@@",
  "billing": {
    "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": {
    "first_name": "John",
    "last_name": "Doe",
    "company": "",
    "address_1": "969 Market",
    "address_2": "",
    "city": "San Francisco",
    "state": "CA",
    "postcode": "94103",
    "country": "US"
  }
}

推荐阅读