Thanks Linda, I hope you'll forgive my choosing to follow the path least trodden!
I've managed to get values entered against Read Only fields handled how I'd like. For the benefit of any others who might stumble across this thread, I'll share how I did it.
There were two main problems encountered.
Firstly, the function zen_has_product_attributes in functions_lookups.php needed a bit of a tidy. The existing code was at odds with the published behaviour of PRODUCTS_OPTIONS_TYPE_READONLY_IGNORED (although the name and published description are a bit confusing) and the test for $not_readonly=='true' was superfluous. The following tidy version meant that it behaved correctly everywhere (and still allowed the default behaviour if PRODUCTS_OPTIONS_TYPE_READONLY_IGNORED was set to '0').
PHP Code:
/*
* Check if product has attributes
*/
function zen_has_product_attributes($products_id, $not_readonly = 'true') {
global $db;
if (PRODUCTS_OPTIONS_TYPE_READONLY_IGNORED == '1') {
// READONLY attributes ARE ALLOWED TO BE ADDED TO CART
$attributes_query = "select pa.products_attributes_id
from " . TABLE_PRODUCTS_ATTRIBUTES . " pa left join " . TABLE_PRODUCTS_OPTIONS . " po on pa.options_id = po.products_options_id
where pa.products_id = '" . (int)$products_id . "' limit 1";
} else {
// regardless of READONLY attributes no add to cart buttons
$attributes_query = "select pa.products_attributes_id
from " . TABLE_PRODUCTS_ATTRIBUTES . " pa
where pa.products_id = '" . (int)$products_id . "' and po.products_options_type != '" . PRODUCTS_OPTIONS_TYPE_READONLY . "' limit 1";
}
$attributes = $db->Execute($attributes_query);
if ($attributes->recordCount() > 0 && $attributes->fields['products_attributes_id'] > 0) {
return true;
} else {
return false;
}
}
Secondly, the value of the option was not being passed into the cart (because the readonly wording was not a form input type).
This was changed by replacing the code in attributes.php below...
PHP Code:
// READONLY
case ($products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_READONLY):
$options_name[] = $products_options_names->fields['products_options_name'];
$options_menu[] = . $tmp_html . "\n";
to read
PHP Code:
// READONLY
case ($products_options_names->fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_READONLY):
$options_name[] = $products_options_names->fields['products_options_name'];
$options_menu[] = zen_draw_hidden_field('id[' . $products_options_names->fields['products_options_id'] . ']', $products_options_value_id) . ' ' . $tmp_html . "\n";
And lo! It all works beautifully.
If I knew how, I'd wrap an
PHP Code:
if (PRODUCTS_OPTIONS_TYPE_READONLY_IGNORED == '1') { ... }
around the $options_menu change so that behaviour was consistent, predictable, optional and compliant (and good for production). But since I didn't (don't) know PHP 'til today, you'll understand why I draw the line once it works for me;-)
Thanks again for your guidance, and I hope the attached proves useful for other novice zenners straying this way,
Keith