加入购物车
方法概览
| 项目 | 内容 |
|---|---|
| 文档类型 | PHP 类方法 |
| 方法标识 | app\home\model\CartModel::createCart |
| 所属业务 | 商品管理 |
| 来源模块/系统 | 购物车模型 |
功能说明
加入购物车
调用示例
$param = ['product_id' => 1, 'config_options' => [], 'qty' => 1, 'customfield' => [], 'self_defined_field' => [], 'products' => [['product_id' => 1, 'config_options' => [], 'qty' => 1, 'customfield' => [], 'self_defined_field' => []]]];
$result = (new \app\home\model\CartModel())->createCart($param);参数
| 参数 | 类型 | 必填 | 默认值 | 校验规则 | 说明 |
|---|---|---|---|---|---|
param.product_id | int | 是 | — | required | 商品ID |
param.config_options | object | 否 | — | — | 自定义配置 |
param.qty | int | 是 | — | required | 数量 |
param.customfield | object | 否 | — | — | 自定义参数 |
param.self_defined_field | object | 否 | — | — | 自定义字段({"5":"123"},5是自定义字段ID,123是填写的内容) |
param.products | array | 否 | — | — | 商品 批量加入购物车必传 |
param.products[].product_id | int | 否 | — | — | 商品ID |
param.products[].config_options | object | 否 | — | — | 自定义配置 |
param.products[].qty | int | 否 | — | — | 数量 |
param.products[].customfield | object | 否 | — | — | 自定义参数 |
param.products[].self_defined_field | object | 否 | — | — | 自定义字段({"5":"123"},5是自定义字段ID,123是填写的内容) |
返回值
| 返回项 | 类型 | 说明 |
|---|---|---|
status | int | 状态码,200成功,400失败 |
msg | string | 提示信息 |
正常返回
{
"status": 1,
"msg": "string"
}异常情况
| 异常类型 | 说明 |
|---|---|
Throwable | 调用失败时由具体实现抛出异常,异常信息以运行时结果为准。 |