Ok, I think I've got it - or at least it works now. I'm posting my solution in the hope it will help someone in the future. Feedback on my approach are appreciated. Thanks,
-)----- B
In header_php.php I modified the query by adding the product_options_type:
PHP Code:
$attributes = "SELECT popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, popt.products_options_type
FROM " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
WHERE pa.products_id = :productsID
AND pa.options_id = :optionsID
AND pa.options_id = popt.products_options_id
AND pa.options_values_id = :optionsValuesID
AND pa.options_values_id = poval.products_options_values_id
AND popt.language_id = :languageID
AND poval.language_id = :languageID " . $options_order_by;
Then after this line:
PHP Code:
$attrArray[$option]['price_prefix'] = $attributes_values->fields['price_prefix'];
I added the following:
PHP Code:
$attrArray[$option]['products_options_type'] = $attributes_values->fields['products_options_type'];
if ($attrArray[$option]['products_options_name'] == 'CustomImageID') {
$productsCustomImageID = zen_output_string_protected($attr_value);
}
The first line exposes the product_options_type to be read from the tpl_shopping_cart_default.php page. The if block detects which option contains the value I need to use in displaying the customized product image in the shopping cart.
I then added 'productsCustomImageID'=>$productsCustomImageID, to the list of values that get stored as an array into $productArray[$i]
PHP Code:
$productArray[$i] = array('attributeHiddenField'=>$attributeHiddenField,
'flagStockCheck'=>$flagStockCheck,
'flagShowFixedQuantity'=>$showFixedQuantity,
'linkProductsImage'=>$linkProductsImage,
'linkProductsName'=>$linkProductsName,
'productsImage'=>$productsImage,
'productsName'=>$productsName,
'showFixedQuantity'=>$showFixedQuantity,
'showFixedQuantityAmount'=>$showFixedQuantityAmount,
'showMinUnits'=>$showMinUnits,
'quantityField'=>$quantityField,
'buttonUpdate'=>$buttonUpdate,
'productsPrice'=>$productsPrice,
'productsPriceEach'=>$productsPriceEach,
'rowClass'=>$rowClass,
'buttonDelete'=>$buttonDelete,
'checkBoxDelete'=>$checkBoxDelete,
'id'=>$products[$i]['id'],
'productsCustomImageID'=>$productsCustomImageID,
'attributes'=>$attrArray);
After I made the above changes, I made the following changes to tbl_shopping_cart_default.php. First I check to see if this product is one of my new customizable products and if it is, I will retrieve the CustomImageID and display the img otherwise I'll let zencart display its own product image:
PHP Code:
if (zen_get_info_page($product['id']) == 'product_customizable_info') {
echo '<img src="'.$product['productsCustomImageID'].'.jpg" />';
} else {
echo $product['productsImage'];
}
And then I modified the foreach loop that displays the attribute options to ignore my attributes that should be hidden
PHP Code:
<?php
echo $product['attributeHiddenField'];
if (isset($product['attributes']) && is_array($product['attributes'])) {
echo '<div class="cartAttribsList">';
echo '<ul>';
reset($product['attributes']);
foreach ($product['attributes'] as $option => $value) {
?>
<?php
if ($value['products_options_type'] == PRODUCTS_OPTIONS_TYPE_HIDDEN) {
echo "\n".'<!-- '.$value['products_options_name'] . ' ' . nl2br($value['products_options_values_name']).' -->'."\n";
} else {
echo '<li>'.$value['products_options_name'] . TEXT_OPTION_DIVIDER . nl2br($value['products_options_values_name']).'</li>';
}
?></li>
<?php
}
echo '</ul>';
echo '</div>';
}
?>
Note: PRODUCTS_OPTIONS_TYPE_HIDDEN was defined in the product_options_types and configuration tables.