WP Woocommerce product database: adding product priceprice
-
Hi,
I’m trying a software that allows me to sync an InDesign document (e.g. a product catalog) with an ODBC data source (like a WordPress database). So far I was able to find a SQL query that retrieves part of the info I want to show (product name, description, etc.), but I need this query to go a bit further, so I can also fetch the corresponding product price.The statement that partially worked is this:
SELECT * FROM wp_database_posts WHERE post_status = ‘publish’ AND post_type LIKE ‘product%’;
if ($result = $mysqli->query($query)) {
printf(“<br>Select returned %d rows.\n”, $result->num_rows);
echo “<table>”;
echo “<thead>”;
echo “<tr>”;
echo “<td>ID</td><td>Termék neve</td><td>Termék linkje</td><td>Termék kép</td>”;
echo “</tr>”;
echo “<thead>”;
while ($row = $result->fetch_assoc()) {
$post_id = $row[“ID”];
echo “<tr>”;
echo “<td>”.$post_id.”</td>”;
echo “<td>”.$row[“post_title”].”</td>”;
echo “<td>”.$row[“guid”].”</td>”;
$query_img = “SELECT meta_value FROM wp_postmeta WHERE meta_key =’_thumbnail_id’ AND post_id = $post_id”;
$result_img = $mysqli->query($query_img);
$img = $result_img -> fetch_assoc();
$query_img_2 = “SELECT meta_value FROM wp_postmeta WHERE meta_key =’_wp_attached_file’ AND post_id = “.$img[‘meta_value’].””;
$result_img_2 = $mysqli->query($query_img_2);
$img_2 = $result_img_2 -> fetch_assoc();
echo “<td>”.$img_2[“meta_value”].”</td>”;
echo “</tr>”;
}
echo “</table>”;
/* free result set */
$result->close();
}
I got it from a forum (I have no SQL knowledge) and I need to know the part that has to be added to it so I can get the price from the corresponding table in the database.
Any help would be much appreciated.
Thanks in advance!
The page I need help with: [log in to see the link]
- The topic ‘WP Woocommerce product database: adding product priceprice’ is closed to new replies.