如何在 bigcommerce api 上创建带有自定义选项的产品?
how to create product with custom option on bigcommerce api?
如何在创建产品时添加颜色和尺寸等自定义选项。有文档:
https://github.com/bigcommerce/bigcommerce-api-php
这是我的代码:
public function addProduct($data)
{
$fields = array(
"name" => $data['name'],
"description" => $data['description']
);
return Bigcommerce_api::createProduct($fields);
}
我需要在产品选项中添加一些数据:$data['color'], $data['size']
怎么做?
您需要创建一个选项集,向该选项集添加选项,然后将该选项集分配给产品。
基本上它看起来像这样:
public function addProduct($data)
{
//create option set
$optionSet = Bigcommerce_api::createOptionsets(['name' => 'tshirts']);
//create option
$option = Bigcommerce_api::createOptions(['name' => 'color', 'display_name' => 'color', 'type' => 'S']);
//.. create option values
//assign option to option set
Bigcommerce_api::createOptionsets_Options(['option_id' => $option->id], $optionSet->id);
$fields = array(
"name" => $data['name'],
"description" => $data['description'],
"option_set_id" => $optionSet->id,
);
return Bigcommerce_api::createProduct($fields);
}
如何在创建产品时添加颜色和尺寸等自定义选项。有文档: https://github.com/bigcommerce/bigcommerce-api-php
这是我的代码:
public function addProduct($data)
{
$fields = array(
"name" => $data['name'],
"description" => $data['description']
);
return Bigcommerce_api::createProduct($fields);
}
我需要在产品选项中添加一些数据:$data['color'], $data['size']
怎么做?
您需要创建一个选项集,向该选项集添加选项,然后将该选项集分配给产品。
基本上它看起来像这样:
public function addProduct($data)
{
//create option set
$optionSet = Bigcommerce_api::createOptionsets(['name' => 'tshirts']);
//create option
$option = Bigcommerce_api::createOptions(['name' => 'color', 'display_name' => 'color', 'type' => 'S']);
//.. create option values
//assign option to option set
Bigcommerce_api::createOptionsets_Options(['option_id' => $option->id], $optionSet->id);
$fields = array(
"name" => $data['name'],
"description" => $data['description'],
"option_set_id" => $optionSet->id,
);
return Bigcommerce_api::createProduct($fields);
}