I have a product (for example, "Desk") which has two attributes (size and life). Size has the values small, medium, and large. Life has the values 7 years and 10 years.

The price is different for each variation. How can I change the price for each variation?

  • It's easier to implement in commerce, It comes in the core. Dec 8, 2014 at 19:12

2 Answers 2


You would need to use the Ubercart Attributes module, which is included in the Ubercart core module. From the Ubercart user guide:

Products are not created equally, and in some cases the customer gets to decide the type of product they want. For example, your store may sell t-shirts, and the customer may find a design they like but need to get it in a certain size. In a situation like this, you will need to take advantage of the product attribute system in Ubercart. It lets you define attributes (like size), give them options (like small, medium, and large), and enable attributes and options on a per-product basis. For an example, check out the Ubercart Beanie on the Livetest.

The module allows you to set different prices per attribute and it is not very difficult to setup really.

Having said that, I prefer the Drupal Commerce way of handling product variations.

  • The main thing which I cant figure out is how to set the one value for the combination of two attributes. I don't want to set the value of each individual attribute.
    – Kashif
    Dec 8, 2014 at 11:04
  • For this you would probably need ubercart.org/project/uc_fixed_price
    – Wtower
    Dec 8, 2014 at 11:09

While attributes are certainly one way of handling variations, (and generally the recommended way) If you want to step into the current way that the big-boys are handling variations which takes you to a different product page when selected, you can easily create variations with Paragraphs, Entity Reference and Views. The one downside is that you have to reference each product with the variant. I haven't had a chance to figure out how to get cer or ref_field to automatically sync the references, however in theory those would probably work.

As a loose guide: 1) Create a paragraph bundle called Product Variant

2) Add a field to the paragraph. Name: Variant Name Type: Text

3) Add a field to the paragraph. Name: Variant Reference Type: Entity Reference

4) Go to your Product Content Type and add a field. Name: Product Variation Type: Paragraphs

4 a) Point the paragraph field to the Product Variant paragraph bundle

5) Create a view Product Variations

6) Set the Format to Jump Menu

7) Add relationships to the entity references:

  • Paragraphs item: Entity with the Product Variation (field_product_variation)
  • Entity Reference: Variant Reference
  • (Content entity referenced from field_variant_reference) Content: Product Variation

8) Add the Title field and make sure it is using the relationship that points to the paragraphs field title (field_product_variation)

9) Set the contextual filter to the Nid of the product using the relationship of the paragraph field_product_variation

10) Add the view to your product page above the "add to cart" form with your favorite insert method (I use Panels)

11) Edit each and every product that will need the variations. Set the Name of that products variation, then choose the nodes through entity reference of the node variations. This must be done for each product within the variation unless you figure out how to get CER or ref_field to work. More on this below.

Again, this is a loose guide to give an idea of how to do it.

enter image description here enter image description here

As shown in the images, the dropdown is not part of the UC attribute system but instead a way to navigate to the respective variant page. From there, you would add attributes to the respective product that might change the characteristics of that particular product.

For example, lets say you have five T-Shirt logo designs that are based on the band FooGoo. Each shirt design has different colors and sizes available. You would use my proposed "Variation" to switch between the product pages of each design, that way each logo design is housed within its own product page, then use the stock UC attributes to handle the color and size of each design.

Given this example, you would have to edit all 5 design product pages. The first we'll give a variation name of "Design 1", the second a variation name of "Design 2" and so-on. For Design 1, add Design 1, Design 2, Design 3 etc as the referenced nodes. Do the same for Design 2 and so-on. Once all 5 products point to each other, the jump-menu will work to switch between all of the pages.

Good luck!

"And they said you need Commerce..."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.