Attribute "Display total price" small suggestion

Posts: 82
Joined: 08/12/2007
Uber DonorBug FinderInternationalizationizer

Heyho.
I annotate this in a discussion with a shop owner:

At the moment (Beta6) if you set the attribute settings to "Display total price", the total price "will only be displayed on products with only one attribute.".

Correctly it must be, that the total price "will only be displayed on products with only one attribute or if the other attributes has no options.".

Can you follow me? Smiling

I fixed that with an extra SQL-Statement in uc_attribute.module, function _uc_attribute_alter_form(). The first two lines are now:

<?php
$numresult
= db_query("SELECT * FROM {uc_product_attributes} WHERE nid = %d AND default_option != 0 ORDER BY ordering", $product['nid']['#value']);
$total_attributes = db_num_rows($numresult);
$result = db_query("SELECT * FROM {uc_product_attributes} WHERE nid = %d ORDER BY ordering", $product['nid']['#value']);
?>

Instead of

<?php
$result
= db_query("SELECT * FROM {uc_product_attributes} WHERE nid = %d ORDER BY ordering", $product['nid']['#value']);
$total_attributes = db_num_rows($result);
?>

$total_attributes now counts only the attributes which have at least one option.

Seems to work for me know. Maybe you want to implement this in the next releases.

Posts: 2267
Joined: 08/07/2007
AdministratoreLiTe!

Sounds good to me. One extra query there shouldn't hurt.

Posts: 304
Joined: 11/19/2007
Bug FinderGetting busy with the Ubercode.

Extremely minor, but the description text on the attribute config screen,
"Formats the price is in the attribute selection form when the customer adds a product to their cart. The total price will only be displayed on products with only one attribute." can be updated to reflect this change.

Posts: 2267
Joined: 08/07/2007
AdministratoreLiTe!

Done.