I don't understand why I am experiencing an error with my variable $product_quantity while its $var_dump($product_quantity) gives the elements. The error points line 63 indicated in the code snippet. moreover It does not get $productInfo['image'] and $productInfo['url']. check output of $var_dump($product_quantity) here
<?php
$arr_products = unserialize($order['products']);
foreach($arr_products as $product_id => $product_quantity)
{
$productInfo = modules::run('admin/ecommerce/products/getProductInfo', $product_id, true);
var_dump($product_quantity);
?>
<div style="word-break: break-all;">
<div>
<img src="<?= base_url('attachments/shop_images/'.$productInfo['image']) ?>" alt="Product" style="width:100px; margin-right:10px;" class="img-responsive">
</div>
<a target="_blank" href="<?= base_url($productInfo['url']) ?>">
<?= base_url($productInfo['url']) ?>
</a>
<--line 63-->
<div style=" background-color: #f1f1f1; border-radius: 2px; padding: 2px 5px;"><b><?= lang('user_order_quantity') ?></b> <?= $product_quantity ?></div>
</div>
<hr>
<?php }
?>
As shown by your var_dump
your array is a multi-level associative array with the parent keys being product_info
and product_quantity
.
I suspect if you change the line in question to <?php echo $product_quantity['product_quantity']; ?>
<?php echo $product_quantity['product_quantity']; ?>
you will no longer have an error.
Also it seems like your $product_quantity
contains your product_info
as well so I'm not sure if this is entirely necessary $productInfo = modules::run('admin/ecommerce/products/getProductInfo', $product_id, true);
(don't know your whole system so I might be wrong)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.