'wordpress import csv finish order
I have a method to read a csv file with one column this is used to set order as completed. but whenever I have more than 20 rows it takes forever to load, the file isn t that big so I am surprised it takes that much time
here is the method used to read the csv
function read_csv()
{
$fileName = $_FILES["file"]["tmp_name"];
$row = 1;
echo '<pre>';
if (($handle = fopen($fileName, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if ($row == 1) {
$row++;
continue;
} // continue is used for skip row 1
if (strlen(trim($data[0]) >= 4)) {
$order = wc_get_order(trim($data[0]));
if (!$order) {
echo $data[0] . " Pas de commande<br />";
} elseif (!Admin::isStaging()) {
$order->update_status('completed', 'order_note');
echo $data[0] . " Completed<br />";
}
}
}
fclose($handle);
}
echo '</pre>';
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
