Black Belt
- Join Date:
- Jul 2005
- Location:
- Upstate NY
- Posts:
- 21,874
- Plugin Contributions:
- 8
Shoppingcart/Freeship in Header support
First off, you need to address the product data with the right number of fields: not
$cart_header_products['linkProductsName']
but
$cart_header_products[$item]['linkProductsName']
so you can output each item's data in turn.
You need to use class= and not id= for the tags, since they will be repeated.
You need to iterate through the products, as the foreach in your previous post did. Foreach has complex behavior that can make it hard to use right without some testing on the particular subject; a simple for() statement will be more reliable here even if it is theoretically less efficient.
The code posted is a mixture of HTML with PHP insertions, and PHP with HTML output strings. It would be clearer to go to all one style, as shown below.
$cart_header_products = $_SESSION['cart']->get_products();
for ($item=0; $item<sizeof($cart_header_products); $item++) {
echo '<a href="' . $cart_header_products[$item]['linkProductsName'] . '"><span class="cartImage" class="back">' . $cart_header_products[$item]['productsImage'] . '</span><span class="cartProdTitle">' . $cart_header_products[$item]['productsName'] . '<span class="alert bold">' . $cart_header_products[$item]['flagStockCheck'] . '</span></span></a>' . "\n";
}