php - I cant delete Woocommerce rest api product from form ← (PHP)

I create delete form but no delete with woocommerce rest api error"Warning: http_build_query() expects parameter 1 to be array, string given in" and "C:\xampp\htdocs\api-woocommerce\vendor\automattic\woocommerce\src\WooCommerce\HttpClient\HttpClient.php on line 138" I dont understad.I can share form and php code;

<?php $i = 1; ?>
                <?php foreach ( $data as $row ) : ?>
                <tr>
                    <td><?= $i; ?></td>
                    <td>
                    <?= $row['id']; ?> 
                    </td><td>
                    <?= $row['name']; ?> 
                    </td><td>
                    <?= $row['permalink']; ?>
                    </td>
                    </td>
                    <td><?= $row['date_created']; ?></td>
                    <td><?= $row['status']; ?></td>
                    <td><?= $row['price']; ?></td>
                    <td><form action="delete_connect.php" name="delete" method="GET">
                    <input type="checkbox" name="id" value="<?= $row['id']; ?>"/>

                </td>
                </tr>
                <?php $i++; ?>
                <?php endforeach; ?>
                <td><input type="submit" name="gönder"/></td></form>

and delete_connect.php;

<?php
$PRODUCT_ID = $_GET['id'];
?>

<?php echo json_encode($woocommerce->delete('products/',$PRODUCT_ID,['force' => true])); ?>

Answer



Solution:

Try changing

<?php echo json_encode($woocommerce->delete('products/',$PRODUCT_ID,['force' => true])); ?>

to

<?php echo json_encode($woocommerce->delete('products/'.$PRODUCT_ID,['force' => true])); ?>

assuming your using this

https://woocommerce.github.io/woocommerce-rest-api-docs/?php#delete-a-product

Source