Commerce custom line items
and other modules required by the above mentioned modules.
Let's start by creating a new product type by going to: admin/commerce/products/types/add
Add a new line item by going to: admin/commerce/config/line-items/add
Save line item type and edit it to add the length and breadth fields as shown below
Now, remember to chose the "Include this field on Add to Cart forms for line items of this type".
Similarly, let's add the breadth field also
After adding the fields, the new line item type should look something as the picture below
After saving the new line item type, lets create a product display (content type to display our product) by going to: admin/structure/types/add
Save the content type and add product reference field to it
Now, lets go to manage display and change the line item type of the product reference field to the one which we created
After saving the changes, lets create a product of the product type we created earlier by going to: admin/commerce/products/add/product
Now we can finally create product display for the product we just created
and save the product display. When we open the product display / node we just created , it should have the length and breadth field and add to cart button
Now, if we add the product to cart, we cannot see the length and breadth field yet, it can be easily fixed by adding the fields to the shopping cart view
similarly, add the breadth field to the view and rearrange the fields and it should look like in the picture below.
Now lets calculate the price for the area (ie. L *B * unit price) using rules
Create a new rule by going to: admin/config/workflow/rules/reaction/add
Now let's add the condition
Repeat the same process for the breadth field also. After that let's add an action.
The calculated value is stored in the variable as shown below.
Let's add another action where we will multiply the unit price by the value calculated above
Set the price component type and price rounding mode as required and save
Now if you add the item to the cart, it should look like this (10*10*15 = 1500)