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.
List price shouldn't be visible when not set (equals to zero).
On views this is already doable using "Count the number 0 as empty" and "Hide if empty" field options; but on product page there is no property to set.
Comment | File | Size | Author |
---|---|---|---|
#5 | 1879340-Hide-List_Price-2.patch | 1.22 KB | mandreato |
#1 | 1879340-Hide-List_Price.patch | 979 bytes | mandreato |
Comments
Comment #1
mandreato CreditAttribution: mandreato commentedA special format/widget for the field in admin/structure/types/manage/product/display would be the optimum, but at the moment this patch is what I can afford.
Comment #2
TR CreditAttribution: TR commentedI see this as a theming issue. If on your site you want to display the list price only in some circumstances, you can customize your site by overriding theme_uc_product_price(). I think a more common use case, if you're using list prices at all, would be to display list price with a strikethrough when the sell price differs from the list price. Setting list price to zero in those cases seems a little odd to me. Regardless, these sorts of things can and should be handled in the theme layer IMO.
Comment #3
mandreato CreditAttribution: mandreato commentedThe use case you described is exactly mine: I set the following CSS statement to indicate as a original price is discounted for a product.
.list-price { text-decoration: line-through; }
But then I don't want to discount all products, so just a few have a list price !=0. I need to hide those with zero and probably it's a very common use case.
Since this behaviour is the same for dimensions (which also disappears when zero), I thought to manage it in Ubercart core, not via customization. Maybe the patch #1 is a rough way and it should have an option somewhere to enable/disable the field display.
Comment #4
longwaveWhile I agree that showing a list price of $0 will be uncommon, the right place to do this is in theme_uc_product_price(), so it can be overridden if necessary, and easily extended to other price fields if necessary. I guess a sell price of $0 is usually valid, while a list price or cost of $0 should probably be hidden by default.
Comment #5
mandreato CreditAttribution: mandreato commentedOK, I changed the patch by moving the exclusion logic into theme_uc_product_price()
Comment #6
philsward CreditAttribution: philsward commentedIdeally, I think we need the ability to disable a product from purchase altogether. I have a separate custom module that will "hide" the price and checkout form but it doesn't yet work with panels or views.
Longterm, I'd love to see this integrated into core, but there's obviously some bugs that need worked out. I can share what I have if anyone is interested...
Comment #7
end user CreditAttribution: end user commentedMight be overboard but if you use views one you node page to display the price info/buy/now button you can set it to be not shown when the field is 0. I believe you have to remove the formating on the price other wise it doesn't work.
Comment #8
meshwetamandreato,
Thanks for the patch this worked for me. I was thinking to write jQuery for the same but your patch is too good. Thanks once again! God Bless You!
Comment #9
mandreato CreditAttribution: mandreato commentedPatch #5 is on my live site since 4 months with no problems.
Comment #10
carlodimartino CreditAttribution: carlodimartino commentedThanks. Patch #5 worked perfectly for me too.
Comment #11
Gemini Lights CreditAttribution: Gemini Lights commentedJust wondering if patch #5 will be committed to a stable release version of Ubercart 7.x-3.x?
Comment #12
Gixxernutter CreditAttribution: Gixxernutter commented+1 on #5 - thanks