10 replies [Last post]
Jmmb's picture
Offline
Joined: 08/23/2007
Juice: 301
Was this information Helpful?

Hello, a client of ours would like to hide the pricing adjustments that appear in the pop-up menu when attributes change the cost of an item. For example, at:

http://www.muskratcoffeeco.com/drupaluber/node/35

the "Weight" variables ( +$4.00, -$2.00, +$72.00 ) should still be in effect when purchasing, just removed from being visible in the pop-up.

I know there is code that will do this, but I'm not sure what it is or where to put it. Our programmer who's done it before is in the hospital, and with the archives difficult to access at present (I tried http://www.ubercart.org/forum/support/11/finding_old_forum_content), I have to ask.

Thanks,

Jim

(Drupal^Ubercart) * (Design^Development^Hosting) = Sundays Energy

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: Hiding Attribute Price Adjustments

The code to look for is in uc_attribute.module, near the bottom of the file in function _uc_attribute_alter_form(). Line 1119 puts the price adjustment on the options. Make it like this to remove it:

<?php
      $opt_array
[$option->oid] = $option->name;
?>
Jmmb's picture
Offline
Joined: 08/23/2007
Juice: 301
Yes!

Yes, that worked perfectly -- good to know it's that easy Smiling

Thanks Lyle,

Jim

(Drupal^Ubercart) * (Design^Development^Hosting) = Sundays Energy

zmove's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Internationalizationizer
Joined: 08/13/2007
Juice: 1192
Re: Yes!

It could be good if the attribute form function was themable, to be able to configure the way you want to show the attribute price without hacking core.. Eye-wink

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: Re: Yes!

Technically, it's part of the 'add_to_cart' form, and someone could theme it through that. But it's added through hook_form_alter(), so that would be messy at best.

I'll add a theme function to the group of attribute elements called theme_uc_attribute_add_to_cart(). That function won't actually exist, but it can be overridden by themes and theme engines like any other. You'll have access to both the select box and the text field attributes, and have complete control of them.

zmove's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Internationalizationizer
Joined: 08/13/2007
Juice: 1192
Like in a dream thank you

Like in a dream Smiling

thank you

emerson's picture
Offline
Joined: 11/12/2007
Juice: 19
theme attribute selection

Hi Lyle,

i want to replace the selection box with buttons. Is this a way to get it done?
If yes, please let me know exactly how - i'm no coder and so i don't exactly understand
how to override a function that "won't actually exist".

Many thankx in advance

emerson

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: theme attribute selection

I don't think theme functions are supposed to change forms like that. I suppose it's possible, but it's not the way I'd recommend doing it. That would be more like a form_alter, so you would need to write a module that had a heavier weight than uc_attribute. Search for "module weight" on drupal.org and you can find posts about it.

drjonez's picture
Offline
Joined: 03/13/2009
Juice: 35
Re: Re: Hiding Attribute Price Adjustments

Is this how we're supposed to solve small issues like this? Edit the module code??

seems unorthodox.

splash112@drupal.org's picture
Offline
Joined: 04/01/2008
Juice: 413
No, It's a setting now.

No,

It's a setting now.

drjonez's picture
Offline
Joined: 03/13/2009
Juice: 35
Re: No, It's a setting now.

Hey thanks!