Please make views see $0.00 as an empty field. I asked on the views queue here (http://drupal.org/node/559102#comment-2814366) and this was merlinofchaos's reply

"I think ubercart is going to have to handle that. Though. Price fields should probably be integers that are converted for display rather than actual strings. But I don't get to control the architecture."

(http://drupal.org/node/559102#comment-2814368)

Ii would be nice to be hide this field on product listings (I used views for my catalog) if the amount is $0.00. Thanks.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

eiland’s picture

Status: Active » Fixed

you can change the field display using field-templates;

Override views-view-field.tpl.php by adding views-view-field--field-PRICE-value.tpl.php to your theme folder and make it

<?php 
if ($row->{$field->field_alias}>0)
{echo $row->{$field->field_alias}."$"; }
else
{echo "for free";}
?>

as per http://views-help.doc.logrus.com/help/views/using-theme.

fehin’s picture

Hi eiland, thank you for your help.
I placed the code below in views-view-field--list-price.tpl.php and all I saw is long "?????????????????" in the list-price field.

What I'm trying to achieve is check to see if list-price is greater than $0.00 and greater than sell-price. If this is true, then list-price prints otherwise the field should be hidden. Is my code not correct? Thanks.

<?php 
if ($row->{$field->field_list-price}>0 && $row->{$field->field_list-price}> $row->{$field->field_sell-price})
{echo $row->{$field->field_list-price}."$"; }
else{
unset($row->{$field->field_list-price});}
?>
eiland’s picture

hi,
sorry im not familiar with übercart but you could try to put

<?php drupal_set_message('<pre>' . var_export($row, true) . '</pre>'); ?> to see whats inside the object.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nyleve101’s picture

Status: Closed (fixed) » Active

Hi,

did anyone find a solution to this issue?

Hope all is well!

Evelyn

GuyPaddock’s picture

Category: feature » bug

Sorry, guys, but this is pretty clearly a bug. This *would* be a feature request if the module hid the "Count the number 0 as empty" checkbox that Views provides by default. Since it does not, this is a bug because UberCart is not honoring the setting.

GuyPaddock’s picture

Patch for this issue is attached.

I've also noticed that if you select "Numeric" for "Display Type", nothing is shown, but this isn't caused by my patch (pre-existing bug). I'll file an issue about it.

GuyPaddock’s picture

Status: Active » Needs review

Setting to "Needs Review".

GuyPaddock’s picture

Same patch, re-rolled for 6.x-2.x-dev

GuyPaddock’s picture

Ignore this patch. See the next one in the thread. I'm not sure why I've handled this issue so poorly...

GuyPaddock’s picture

This one is the *actual* re-roll for 6.x-2.x-dev with bug fix. The previous version in #9 wasn't detecting zero properly, and #10 was saved by Google Chrome via a download from one system to another, so it got converted to HTML.

longwave’s picture

Status: Needs review » Needs work
longwave’s picture

Version: 6.x-2.2 » 6.x-2.x-dev
Status: Needs work » Needs review
FileSize
994 bytes

This patch is simpler and seems to work for me.

longwave’s picture

FileSize
784 bytes

This patch is more true to the original code, and also fixes the "Hide if empty" checkbox so the field can be hidden for nodes which are not products, as noted in #356919: price handler returns an apparent zero price for non-product

mandreato’s picture

Status: Needs review » Reviewed & tested by the community

Good news: this patch works !
Bad news: I've to patch uc_vat too, because uc_vat_handler_field_price extends uc_product_handler_field_price so also its render function needs to be revisited in the same manner...

OT: @longwave uc_vat seems to have some important bugs... do you plan to still mantain that module, or you think to leave it behind, since it's not needed anymore in Ubercart 7.x-3 ?

longwave’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Committed #15 to 6.x, needs porting to 7.x.

@mandreato: uc_vat will get fixed if I find the free time, or someone else submits a fix. I don't intend to port it to 7.x, as inclusive taxes are handled in Ubercart core, and the other features should probably be moved into core as well.

mandreato’s picture

Thank you very much longwave !

longwave’s picture

Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

sarhansg’s picture

Sorry to post in a closed topic. However, the patch does not work for List and Cost price. In the site I am working on we show List and Cost price in the view so visitors can easily compare the mark-down value. However, when Cost price is $0 it is still shown. I'm using 6.x-2.x-dev version where the patch has already been implemented.