You have two tables in the question, with different details on the same products. One thing you never want to do is duplicate data across tables. It is wasteful of resources and risks the integrity of the data. Ex. if the name of a product changes, you will have to modify it in many tables. If you miss one, the application will have issues since it will not always receive the same name. You can read about data normalization.
To perform queries on two tables, you use a JOIN operation. One value that is unique to each product, and appears in both tables is product_id.
Ex, get the products name from lcqu_products_info
SELECT name
FROM lcqu_products_info
Ex, get the price from lcqu_orders_items
SELECT price
FROM lcqu_orders_items
Now if you need the name AND the price in a single query, join the tables with the product_id:
SELECT pi.name, oi.price
FROM lcqu_products_info AS pi
LEFT JOIN lcqu_orders_items AS oi ON pi.product_id = oi.product_id
Based on that, you should remove the "name" column from the lcqu_orders_items. The name should be extracted from the lcqu_products_info, using the same methos showed above.
Now about your PHP code:
<?php
foreach ($order['items'] as $item)
{
?>
<tr>
<td>
<?php echo (float)$item['quantity']; ?>
</td>
<td>
<?php echo $item['sku']; ?>
</td>
<td style="white-space: normal;">
<?php echo $item['name']; ?>
<?php
if (!empty($item['options']))
{
foreach ($item['options'] as $key => $value)
{
echo '<br />- '.$key .': '. $value;
}
}
?>
In this code you require these values from lcqu_orders_items
- quantity: in the table
- sku: in the table
- name: in the table. Should not be. It should be taken from lcqu_products_info
- options: in the table.
Therefore the query should be:
SELECT oi.quantity, oi.sku, pi.name, oi.options
FORM lcqu_orders_items AS oi
LEFT JOIN lcqu_products_info AS pi ON oi.product_id = pi.product_id
the results of this query will end up into the $orders array, on which you can loop and print the data.
I understand this is not a direct answer to your question, but such an answer would send you down a path that is not best practice, and cause you problems later.
product_idto get all the information that you need?echo $item['product_id', 'short_description'];but did not work<?php foreach ($order['items'] as $item) { ?> <tr> <td><?php echo (float)$item['quantity']; ?></td> <td><?php echo $item['sku']; ?></td> <td style="white-space: normal;"><?php echo $item['name']; ?> <?php if (!empty($item['options'])) { foreach ($item['options'] as $key => $value) { echo '<br />- '.$key .': '. $value; } } ?>and the information are taken from the tableorder_itemin the above picture.