blog

"Requiring" Attributes in Ubercart

March 20 2010 by Anya Petersen

Attributes in Ubercart can be "required", but what does this mean? My first impression was that I should check "required" if I did not want a user to be able to add the product to their cart without setting the value for that attribute. In fact, the attribute will be set whether or not it is "required". The difference is that "requiring" the attribute ignores the default value and forces the user to actively set the value of the attribute before adding the product to their cart.

Let's say you are selling a T-Shirt with a size attribute and options S, M, L. You set up default to be L in the options tab for that product. If you DO check required on the attributes tab for the product, the product display will show "please select" until the user chooses a size. If you do NOT check required, the product display will show "L" unless the user changes it. Either way, the value of "Size" will be set before the shirt is added to the user's cart.

Anya Petersen

Anya Petersen

Anya likes patterns and finding simple solutions to complicated problems. She has been programming for more than 10 years, picking up degrees in CS and Applied Mathematics along the way.

When not coding, Anya can be found on the track training with one of the world's top roller derby leagues.

Tags