Using Wordpress, Woocommerce, WP ALL IMPORT Plugin to import products.My CSV has a JSON formatted data and a php List formatted data.
example: a colomn named colors in JSON format and another named food in PHP List format.
JSON: {"Color-1":"Red","Color-2":"Green"}List: ["Pizza", "Burger", "Salad", "Pasta", "Sushi"]
in the Function Editor in the plugin i made a simple function to process the data:
<?phpfunction processData($jsonObject, $array) { // Decode JSON data into PHP array $object = json_decode($jsonObject, true); // Check for JSON decode errors if ($object === null) { return 'Error decoding JSON data.'; } // Initialize result string $output = ''; // Loop through the associative array and format the key-value pairs foreach ($object as $key => $value) { $output .= "$key $value\n"; } // Format the array elements foreach ($array as $item) { $output .= $item . "\n"; } // Return the result return $output;}?>
Then in the description text editor i used the function like this:
[processData({colorscolomn[1]}, {foodcolomn[1]})]
the json did work perfectly no problem. but i have tried everything for the list and it just never shows. am i missing something?
How can i loop through a list in wp all import programtically in php?
Here are some images to have an idea what i'm talking about.