Here's something you can TRY. I've *NOT* tested this thoroughly, but at a cursory level it appears to allow you to set a product price AND flag the product as priced-by-attributes AND have it auto-calculate the lowest "starting at" price when negative prices are used for attributes.
/includes/functions/functions_prices.php
somewhere around maybe line 115 you'll have a "zen_get_products_base_price" function definition, which starts with these lines:
Code:
function zen_get_products_base_price($products_id) {
global $db;
$product_check = $db->Execute("select products_price, products_priced_by_attribute from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
// is there a products_price to add to attributes
$products_price = $product_check->fields['products_price'];
// do not select display only attributes and attributes_price_base_included is true
$product_att_query = $db->Execute("select options_id, price_prefix, options_values_price, attributes_display_only, attributes_price_base_included from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and attributes_display_only != '1' and attributes_price_base_included='1'". " order by options_id, price_prefix, options_values_price");
$the_options_id= 'x';
$the_base_price= 0;
// add attributes price to price
if ($product_check->fields['products_priced_by_attribute'] == '1' and $product_att_query->RecordCount() >= 1) {
while (!$product_att_query->EOF) {
if ( $the_options_id != $product_att_query->fields['options_id']) {
$the_options_id = $product_att_query->fields['options_id'];
$the_base_price += $product_att_query->fields['options_values_price'];
}
$product_att_query->MoveNext();
}
.......
Try changing the 2 lines highlighted above with their respective replacements shown below:
2 changes in this line:
Code:
$product_att_query = $db->Execute("select options_id, price_prefix, options_values_price, attributes_display_only, attributes_price_base_included, round(concat(price_prefix, options_values_price), 5) as value from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and attributes_display_only != '1' and attributes_price_base_included='1'". " order by options_id, value");
and 1 change in this line:
Code:
$the_base_price += (($product_att_query->fields['price_prefix'] == '-') ? -1 : 1) * $product_att_query->fields['options_values_price'];
Bookmarks