How would I put a product's options followed by the values under the item in the infobox shopping cart. The current infobox shopping cart only shows the item's name, but it is a problem when one wants to have the same item in the cart but with different attributes.
The infobox shopping cart has a function located in the shopping cart class to get the info needed for display like this:
$products = $cart->get_products_with_attr();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
The info is then then displayed like this: $cart_contents_string .= $products[$i]['name'];
The function that gets this info from the database is this: (Note: I renamed the function because it is used in other parts of the code and I did not want to break any other code.)
function get_products_with_attr() {
global $languages_id;
if (!is_array($this->contents)) return false;
$products_array = array();
reset($this->contents);
while (list($products_id, ) = each($this->contents)) {
$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
if ($products = tep_db_fetch_array($products_query)) {
$prid = $products['products_id'];
$products_price = $products['products_price'];
$specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");
if (tep_db_num_rows($specials_query)) {
$specials = tep_db_fetch_array($specials_query);
$products_price = $specials['specials_new_products_price'];
}
$products_array[] = array('id' => $products_id,
'name' => $products['products_name'],
'model' => $products['products_model'],
'image' => $products['products_image'],
'price' => $products_price,
'quantity' => $this->contents[$products_id]['qty'],
'weight' => $products['products_weight'],
'final_price' => ($products_price + $this->attributes_price($products_id)),
'tax_class_id' => $products['products_tax_class_id'],
'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));
}
}
return $products_array;
}
I found another post from 5+ years ago that said how to do this, only the advice giver never tried it out himself and it worked partially, but it was not an array or the array was being put together incorrectly. Will you please help me with this. If you don't object, I'll turn this into a contribution.
Thank you very much, Luc









