正在构建新的解决方案,以添加woocommerce产品及其变体,但是在将变体添加到产品中时却出现了一个奇怪的错误。有时会出现错误,有时不会!
使用woocommers rest api php库,我还想知道是否有任何好的方法可以在一个请求中添加带有其龋齿的产品!
$finalJS = json_decode($vardata,true);
$finalarr = array();
foreach($finalJS as $key=>$value){
if($key == "image"){
// $finalData .= "'image' => ['src' => '".$value."'] ";
}
else {
$finalarr[$key]=$value;
}
}
// print_r($finalarr);
echo '</br>';
echo $productID;
$woocommerce->post('products/'.$productID.'/variations', $finalarr);
error message:
Uncaught exception 'Automattic\WooCommerce\HttpClient\HttpClientException' with message 'cURL Error: Operation timed out after 15007 milliseconds with 2680 bytes received' in C:\xampp\htdocs\test\vendor\automattic\woocommerce\src\WooCommerce\HttpClient\HttpClient.php:417