6 replies [Last post]
leenwebb's picture
Offline
Joined: 06/01/2008
Juice: 248

Hi,
As long as I'm asking questions... Has anyone come up with an elegant way to deal with a product whose base price is $0?

The situation:
One of our products is essentially "Buy time with our strategist or senior partner". The way I've set it up is that the product itself has a price of $0, and then there are two attributes ("Time with a Senior Partner" and "Time with a Strategist") that each have a couple of time/price options.

Functionally, this works just fine. (I suppose someone could be all crazy-go-nuts and add the product to the cart without any time options chosen, but I don't think I really care.) But aesthetically, it's kind of weird -- the price displays as a big-ol'-zero on the page and in the product list.

My only thought is that I can go into the code and say, "if display_price=0, then don't display it at all" and that would at least hide the silly $0 price, but I'd love to hear if any other Ubercarters have run into anything similar and how you solved the issue.

Thanks!
Eileen

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Re: Elegant way to deal with a product with a base price of $0 ?

I think no matter how Ubercart handles it, the best way would be to edit that in your theme.. just as you suggested, a conditional, placed in your product-node.tpl.php (or into the Contemplate - product template), you can check the price of an item and choose to display the word "free" if the price is 0, otherwise show the price.

That might be something that could be added into Core - our old system would actually look for the word "FREE" added to the product's data itself, not 0.00.

--
Help directly fund development: Donate via PayPal!

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15422
Re: Elegant way to deal with a product with a base price of $0 ?

Duck feet! Those are duck feet! For some reason I kept seeing a stretched out starfish... Puzzled

I'm not sure if there's an easier solution than the one discussed here for the current functionality. Only other thing to do would be to make them separate products or choose one to be a default and the other to be considered an upgrade.

leenwebb's picture
Offline
Joined: 06/01/2008
Juice: 248
Re: Re: Elegant way to deal with a product with a base price of

If we're going to be technical about it, they are goose feet. The goose in question, Spruce, had comically large feet when she was small (all of three weeks ago). She has grown into them a little more since then. She still tries to eat my hat when I lean down to say Hi, though.*

I have actually discovered the perfect way to deal with the $0 price -- the Ajax Attribute Calculation module! Now I've set the default price $250 (the cost of half-an-hour with the partner) and adjusted the other attributes accordingly. When someone changes their options, the display price changes to reflect the new choices, and voila! Perfect.

* There are way too many more pics of Spruce and the rest of the geese and ducks at webmeadow.com/blog . It is hard to get cuter than tiny baby ducks.

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15422
Re: Re: Re: Elegant way to deal with a product with a base price

hah! Thanks for sharing. The pics are awesome. Laughing out loud I'm glad I know what an eft is now, too. Gonna pass it onto my wife... I'm sure she'll appreciate it. Eye-wink

A bit back on topic, I'm sure cYu will be happy you were able to get some good mileage out of his contribution.

cYu
cYu's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 11/19/2007
Juice: 850
Re: Re: Re: Re: Elegant way to deal with a product with a base p

Yeah, now that people are actually using that module a bit I think it might be worth revisiting the whole AJAX part of it. Seems to be unnecessarily complex to have the module doing AJAX calls for attribute prices instead of loading those into javascript arrays on page load and updating the prices from there. I believe the only upside to the current approach is that it saves on initial page load if there are a ridiculous amount of attributes and options, but the downside of the relative slowness of AJAX calls probably outweighs this.

oliver coleman's picture
Offline
Bug Finder
Joined: 01/09/2008
Juice: 210
Hack for product.module to add CSS class when price is zero

I modified function theme_uc_product_sell_price($price, $teaser) in product.module to add a CSS class to the sell_price div on product nodes (and maybe elsewhere?) when the price is $0 so that simple CSS can be optionally used in a theme to not display the price when it's $0, eg div.zero_price { display: none; }

See http://www.ubercart.org/contrib/7395