![](/img/trans.png)
[英]Woocommerce REST API image upload woocommerce_rest_invalid_remote_image_url
[英]Woocommerce rest api category and image upload/add problem
我可以为 woocommerce rest api.name、价格或描述写产品表格,但如果我添加到单个类别或仅添加到单个图像链接,则可以共享表单错误;首先回复
<input type ="checkbox" name="test1" id="test1" value="16" /><br>///value is category id
<input type ="checkbox" name="test2" id="test2" value="17" /><br>///value is category id
和 php post sciprt;
$test1 = $_POST['test1'];
$test2 = $_POST['test2'];
$data =
[
'categories' => [
[
'id' => $_POST['test1'],
],
[
'id' => $_POST['test2'],
]
],
];
<?php echo json_encode($woocommerce->POST('products', $data)); ?>
如果我只能选择“test1”或“test2”按钮,出现以下错误代码
Notice: Undefined index: test2
Notice: Undefined index: test1
我已经添加了一个系列并尝试了很多次,但我无法成功。 你能帮助我吗? 如何进行单一选择并添加产品?
您提供的 HTML 代码表明有两个不同的复选框组。 如果你想做一个。 保持所有名称属性相同。
<input type ="checkbox" name="test[]" id="test1" value="16" />
<input type ="checkbox" name="test[]" id="test2" value="17" />
当没有选中复选框时, PHP 将不会收到任何名为test
的 POST 数据。 要检查这一点,您可能需要在使用它之前进行检查。
if(isset($_POST['test'])){
foreach($_POST['test'] as $report_id){
echo "$report_id was checked! ";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.