11 replies [Last post]
konaseema's picture
Offline
Joined: 01/27/2010
Juice: 39
Was this information Helpful?

I have to change this in two places:

1) Product page [if list price has any value, it should show both list price and sale price]; or if list price is more than sale price, should show both as: Was:$20; Now: $10
2) Product view: I created a view based on products; I tried including the list price and hide it when there is no value entered. It is not working because drupal defaults the value to "0.0". I even checked, consider "0" as empty; but probably because the value is "0.0", it is not working; any other suggestions?

Thanks,

Alaska's picture
Offline
Joined: 10/16/2007
Juice: 1433
Nifty Products
konaseema's picture
Offline
Joined: 01/27/2010
Juice: 39
Re: Nifty Products

I saw that thread. Need to change alot in that template file to use it for my purpose. Plus it will only work for product page; how about views? I hope i can do it in "phptemplate_uc_price" in template.php.tpl, but not sure how to do it Sad

iamnoskcaj's picture
Offline
Joined: 07/23/2010
Juice: 6
Hiding empty (0.0) list price in Views

As cool as that linked thread is, I think the OP was talking about hiding the list price in a VIEW. It doesn't work, because of how he described. You can check "hide if empty" and set "Count the number 0 as empty" but it still shows up. It's possible this is happening because the list price is 0.0 or 0.00

If anyone has any advice, I'm all ears!

iamnoskcaj's picture
Offline
Joined: 07/23/2010
Juice: 6
Re: Re: Nifty Products

I have logic in my template.php.tpl to hide the list price on the product page if it's empty, and I setup my custom product.php.tpl just fine.... but I'm not sure how to theme my view, to tell it to use the same logic.

Will post back if I find anything.

mogop's picture
Offline
Joined: 09/07/2010
Juice: 34
Re: Re: Re: Nifty Products

any progress with that ?

jasom's picture
Offline
Joined: 04/13/2008
Juice: 121
Re: How do i show List price only when it is not zero?

any progress?

--
Problem with ubercart?
First:
google.com > site:ubercart.org my problem description > enter
google.com > site:drupal.org my problem description > enter

jasom.net

mogop's picture
Offline
Joined: 09/07/2010
Juice: 34
Re: Re: How do i show List price only when it is not zero?

I've created new CCK Field named - "Old Price" where I enter the old price of the product and show that Field in Views instead of List Price.

maestrojed's picture
Offline
Joined: 08/28/2008
Juice: 11
My approach

I had this same issue. Since we were already using list price in other areas of the site I did not want to create another field just to get it to work with Views. This was my approach:

In my view there is the option "Theme: Information". In there I was able to get a template name for this field. It was:
views-view-field--list-price.tpl.php.
Yours might be the same but it might not.

I then made a file of this name and saved it in my themes directory.

The normal content of this tpl would be:

<?php
print $output;
?>

which outputs:
<span class="uc-price-product uc-price-list_price uc-price">$299.99</span>

So I just strip that down to the price and see if its set to $0.00:

<?php

if(substr(strip_tags($output),-5)!="$0.00"){
    print
$output;
}
?>

This approach does make a few assumptions like there will only be html tags wrapping a price that is in the format of $XXX.XX. Fortuantly it will degrade well and just show the price if it fails.

I hope it helps someone.

jasom's picture
Offline
Joined: 04/13/2008
Juice: 121
Re: My approach

it didnt work for me, i have used "new cck number" field solution

--
Problem with ubercart?
First:
google.com > site:ubercart.org my problem description > enter
google.com > site:drupal.org my problem description > enter

jasom.net

lrobeson's picture
Offline
Joined: 02/17/2011
Juice: 11
Re: My approach

This worked for me, thank you! I was hesitant to add a new CCK field, I wanted to use the native UC fields but the "Count the number 0 as empty" setting in my View wasn't working since it kept changing 0 to 0.00. Adding this views-view-field--list-price.tpl.php did the trick.

Sara Martin (not verified)
Sara Martin's picture
Re: How do i show List price only when it is not zero?

i would like to suggest you you create the Order with a particular Price List and then add multiple Products to the Order by adding Order Lines...