Vote up!
Vote down!

Product based on width, length with stock and price table feature


I've been using Drupal for quite a time, including Ubercart and Commerce, but this time I can't find a solution for more than a week.

Here is my scenario:
I'm selling blades, they come in a roll with a specific width and length to my warehouse and I want to sell them online by length and width. For example I have a roll of the blade "Model" with a width of 16 millimeters and a length of 2000 millimeters.
The stock is referenced by the length, I installed the commerce stock module and renamed it's label to "Length", but I also want to use a price table (I use this price table) for discounts based on how many items the customer buys, but this module calculats the price based on the "quantity" field, the same one that the stock module uses. For example if a customer wants to buy 5 items of the same width but with different lengths or just 5 items of the same width and length this method doesn't work :(
I tried looking at the Rules that the both modules work with and create and input field using custom products module for the length field, but again no luck, no stock for length.

For a better understanding of what I am trying to achieve you can take a look here, it's the exact thing.

I also tried product option, but no luck again. I can't see any solutions anymore. I might be able to write some code if I'm pointed in the right direction.

I will highly appreciate any suggestions to my problem.


Asked by: Banzai
on April 28, 2013

1 Answer

Vote up!
Vote down!


What you need is a configurable product that changes the base price based on line item fields. I've created something similar for a pizza shop website that changes the price based on the ingredients that you choose.


This video uses price fields attached to vocabulary terms. But you could just use a "list" field of integers and use them for your length.

The trick would be to see how the price table generates it's prices ... chances are you would need to tweak the weight values to make sure your pricing calculation happens before the pricing table calculation happens.


Josh Miller
Answer by: Josh Miller
Posted: Apr 30, 2013


Thanks for your answers, your solution was brilliant, really helped me!

- Banzai on May 4, 2013