6 replies [Last post]
doob31's picture
Offline
Joined: 08/30/2007
Juice: 9
Was this information Helpful?

We would like to be able to add multiple sections in the attributes section but also have the user only choose one. example: We are selling posters and the user can choose a poster size and Material. Also we would like to be able to show the final price of choosing that option and not the additional price

Canvas
o 8x10.....$20
o 16x20....$30
o etc......($$)

Bond
o 8x10....$15
o etc....($$)

We would also like this to be themeable.

I understand you guys can't do everything but I am very new to drupal and ubercart. I do think greater customization of how the attributes work would be a great addition to ubercart so I decided to add this idea here.

If someone could help me out on a description or example of how I may achieve something like this then I think I could do it. I am still having a little trouble understanding the development and api fundamentals of drupal, though.

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

I say the same thing before the website crash, but I'm totally agree with you.

I think the attribute module could gain in flexibility and become more more more usefull by adding the possibility to show the new price instead of the additionnal price.

I think if only one options would be in, it should be the new price because the additionnal price is not so usefull and only some marginal website will need it.

But the best should lets to store owner to choose by adding an options into admin attribute form.

And, if I can add another suggestion related to attribute, is to add the possibility to show, in the catalog the list of the attributes and the possibility to directly add them to cart without the obligation to enter in the product node.

And, the last but not the leadt Smiling, to display the attribute name in the shopping cart block Smiling

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Agree

@zmove: "And, the last but not the least Smiling, to display the attribute name in the shopping cart block Smiling "

Hey, I did this today. Check it out on the Livetest for now. It's a preliminary implementation that I don't know if I'm satisfied with yet. I'm open for any ideas for improvement.

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

Perfect Ryan, as always..... perfect Smiling

StephenGWills's picture
Offline
Uber DonorBug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Not Kulvik
Joined: 08/07/2007
Juice: 414
Re: Advanced attribute features

Just to be a total pain in the butt.... I need to display attributes with radio buttons instead of in a drop-down box. I had this working by hacking uc-attributes.module and, of course, got a well deserved spanking when I moved over alpha code from Bazaar and wiped out my changes and disconnected my radio-button attr's from my products! LOL! DOH!

The moral is... Don't hack modules at home! Bug the trained professionals!!!

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Advanced attribute features

lol You can actually change the select to radio buttons using hook_form_alter(). In fact, it would take very little code if you've got a module in place to drop it in!

jonk's picture
Offline
Joined: 08/12/2010
Juice: 25
Hey guys, I'm trying to mod

Hey guys,
I'm trying to mod the form element on the product page. I'm using a dropdown box to choose my attribute option, and it would be nice for the dropdown to show stock in addition to attribute name and price. For example, a "sweater" product has size attributes, and the size attribute dropdown currently says "Large, $10.00." If there are 50 in stock, I'd like it to say "Large, 50 @ $10.00"

I think the code I need to modify is in the attributes.module file, specifically the line
  $display_price = in_array($attribute->aid, $priced_attributes) ? ', '. uc_price($price_info, $context) : '';

from following block

// Loop through each product attribute and generate its form element.
  foreach ($attributes as $attribute) {
    $context['subject']['attribute'] = $attribute;
    // Build the attribute's options array.
    $options = array();
    foreach ($attribute->options as $option) {
      $context['subject']['option'] = $option;
      switch (variable_get('uc_attribute_option_price_format', 'adjustment')) {
        case 'total':
          $context['type'] = 'product';
          $context['subject']['node'] = $product;
          $price_info = array(
            'price' => $product->sell_price + $option->price,
            'qty' => $qty,
          );
          $display_price = in_array($attribute->aid, $priced_attributes) ? ', '. uc_price($price_info, $context) : '';
          if (count($priced_attributes) == 1 && $attribute->display != 3) {
            break;
          }
        case 'adjustment':
          $context['type'] = 'attribute_option';
          $price_info = array(
            'price' => $option->price,
            'qty' => $qty,
          );
          $display_price = ($option->price != 0 ? ', '. ($option->price > 0 ? '+' : '') . uc_price($price_info, $context) : '');
          break;
        case 'none':
        default:
          $display_price = '';
          break;
      }
      $options[$option->oid] = $option->name;
      if ($attribute->display == 2) {
        // Select options are check_plain()ed, but radio button labels are not.
        $options[$option->oid] = check_plain($options[$option->oid]);
      }
      $options[$option->oid] .= $display_price;
    }

Thanks