Closed (won't fix)
Project:
Ubercart
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
10 Jan 2009 at 14:55 UTC
Updated:
16 Jul 2013 at 17:01 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
rszrama commentedThe price field will pass whatever it finds for the product price through uc_currency_format(), which adds the currency sign and decimal places. Unfortunately, for your non-product nodes it's passing 0 into the function and getting $0.00. I don't think we can really filter this in our Views integration, because we really do need to support products having a $0.00 price. I don't have any recommendations for this, but I am just going to mark it "by design" for now.
Comment #2
joachim commentedIs this a problem with how Views returns data then?
Comment #3
rszrama commentedI'm not so sure... it could just be a data type issue, but I'm not sure if Views will differentiate between a NULL and 0 value.
Comment #4
joachim commentedTry this in uc_currency_format():
It correctly distinguishes in a view between a product with sell price at zero and a non-product node -- views returns NULL for a non-product and zero for the free product.
However, the cart block shows a NADA. But that's something to fix in your code ;)
Comment #5
cha0s commentedPatchies! Just missed a $total = 0 in 1.x.
Comment #6
joachim commentedIt should return NULL or '' if the value is NULL -- not every view will be laid out in a way that the presence of an 'N/A' will make sense. You might have a list view with no labels, for example.
The 'NADA' in my example was just for testing :)
Comment #7
Island Usurper commentedComment #8
cha0s commentedComment #9
Island Usurper commentedIn UC 2, at least, the views handler still prints "Sell price:" when given a NULL value from uc_currency_format(). I suppose that's still better than $0.00, but I'm not worried about it. I don't think you should make views that have several node types but load fields that only apply to some of them anyway.
Committed to both branches, but I didn't include the change to uc_cart.module in the 1.x patch. It seemed like a mistake because it didn't really belong to this issue. If it's still a change that needs to be made, I guess make another issue for it.
Comment #12
joachim commentedI'm reopening this.
I think it should be handled at the uc_price level rather than the views handler.
uc_price should display nothing if the price is NULL rather than 0 or a non-zero value.
Regarding mixing products and non-products: there are tons of use cases for this, and every client site I've done has asked for this. They want views of:
- recent content on the site
- user bookmarks
- taxonomy listings
- featured cool stuff on a front page panel -- basically a total mix of *anything*
and because they want to sell stuff, they want to show the price when it is applicable.
For products alone there are use cases too: I am working on a site where products can be flagged as out of print and a custom module alters the price to null to reflect this -- but if uc_price then prints my null as a £0 then that doesn't look right at all.
Comment #13
joachim commentedFurther problems:
If a shipping method returns a 0 price (eg free shipping) then the quote is shown as 'null'.
EDIT: ignore this comment; it's to do with uc_notforsale.
Though see #821528: prince handler formatters need access to the $context data which to do with it.
Comment #14
nyleve101 commentedignore
Comment #15
ñull commentedbump
i.m.h.o. uc_currency_format() should distinguish null (an empty field or variable), zero (there is a numeric value zero) and any other value. When there is an empty variable it should return that so that views can use the "hide if empty" functionality. When a product is free, then it should be set the numerical value zero.
An example makes this logic clear. The list price in the product content type is by default empty or null. That does not mean the the list price is zero or free. No it means that the user decided not to use the list price. Then the uc_currency_format should mess with it and make it into something that it isn't. Everybody would like to hide the list price in a view when it is not used instead of seeing it untruthfully displayed $0.00, for free.
For those that still need a work around, here is one:
drush dl views_php; drush -y en views_phpComment #16
Anonymous (not verified) commentedHello;
ñull, your solution is really good thank you very much. As expected, no price is displayed for non-product nodes in my view. But how would you do to output the themed price with VAT etc ? Actually I used this code :
It returns the numeric price without VAT
Thank you.
Comment #17
longwaveThe Views fix for this is being dealt with in #764768: "Count the number 0 as empty" check box in views doesn't recognize $0.00 as 0
Comment #18
longwaveNot worth fixing this now, and the price handler is gone in 7.x-3.x.