Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comments
Comment #1
eiland CreditAttribution: eiland commentedyou can change the field display using field-templates;
Override
views-view-field.tpl.php
by addingviews-view-field--field-PRICE-value.tpl.php
to your theme folder and make itas per http://views-help.doc.logrus.com/help/views/using-theme.
Comment #2
fehin CreditAttribution: fehin commentedHi 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.
Comment #3
eiland CreditAttribution: eiland commentedhi,
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.Comment #5
nyleve101 CreditAttribution: nyleve101 commentedHi,
did anyone find a solution to this issue?
Hope all is well!
Evelyn
Comment #6
GuyPaddock CreditAttribution: GuyPaddock commentedSorry, 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.
Comment #7
GuyPaddock CreditAttribution: GuyPaddock commentedPatch 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.
Comment #8
GuyPaddock CreditAttribution: GuyPaddock commentedSetting to "Needs Review".
Comment #9
GuyPaddock CreditAttribution: GuyPaddock commentedSame patch, re-rolled for 6.x-2.x-dev
Comment #10
GuyPaddock CreditAttribution: GuyPaddock commentedIgnore this patch. See the next one in the thread. I'm not sure why I've handled this issue so poorly...
Comment #11
GuyPaddock CreditAttribution: GuyPaddock commentedThis 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.
Comment #12
longwaveMarked #1303506: List price on views: how to hide if zero ? as duplicate
Comment #14
longwaveThis patch is simpler and seems to work for me.
Comment #15
longwaveThis 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
Comment #16
mandreato CreditAttribution: mandreato commentedGood 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 ?
Comment #17
longwaveCommitted #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.
Comment #18
mandreato CreditAttribution: mandreato commentedThank you very much longwave !
Comment #19
longwaveFixed in 7.x: http://drupalcode.org/project/ubercart.git/commitdiff/7b492e2
Comment #21
sarhansg CreditAttribution: sarhansg commentedSorry 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.