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

$arr_products = unserialize($order['products']);

foreach($arr_products as $product_id => $product_quantity)
    $productInfo = modules::run('admin/ecommerce/products/getProductInfo', $product_id, true);
    <div style="word-break: break-all;">
            <img src="<?= base_url('attachments/shop_images/'.$productInfo['image']) ?>" alt="Product" style="width:100px; margin-right:10px;" class="img-responsive">
        <a target="_blank" href="<?= base_url($productInfo['url']) ?>">
            <?= base_url($productInfo['url']) ?> 
        <--line 63-->
        <div style=" background-color: #f1f1f1; border-radius: 2px; padding: 2px 5px;"><b><?= lang('user_order_quantity') ?></b> <?= $product_quantity ?></div>


<?php }

1 Answers

Alex On Best Solutions

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']; ?> 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)