2
Answers
Vote up!
0
Vote down!

Calculation of Price

I've been looking for a solution for the next case for a while :

Let's say I have a product which price is calculated via height and width, like silk for example. You calculate the price multiplying height * width (+1) * silk cost.

How can I make this in DC? So far I have created and customized the whole sales process (since I don't want to checkout, only to make and manage orders) but the last thing is to get this kind of formulas work. I created one field for width, another one for with, another one for silk type as a list (which variates the cost) as Option Sets for the product type. Since it's dimensions are custom I can't just create infinite products, also since there are some types of products aside from silk that require another formula (height * (width * 1.2) +1)... I'm just confused, I tried making this with rules but I got lost.

Any idea anyone?

Update : If there's a way to use the variables on the Option Set of the product, that should be enough, even throug code, that will really help.

Asked by: Ganzeiba
on April 27, 2013

Comments

2 Answers

Vote up!
2
Vote down!

I tried a simple Pricing Rule that takes into account the height and width (+1) for Silk products. Height and Width are added via a custom line item (using http://drupal.org/project/commerce_custom_product). That seemed easy enough, but tested via adding them on the Shopping Cart.

Now, for making those fields to appear on the "Create an Order" form `/admin/commerce/orders/add`, I think you need to use hook_commerce_line_item_type_info() to add a custom "add_form" callback and show those fields when clicking on the "Add line Item" button.

For more ideas/inspiration, check the file contrib/commerce_shipping/commerce_shipping.module
Lines:
700: * Implements hook_commerce_line_item_type_info().
702:function commerce_shipping_commerce_line_item_type_info() {

HTH

Answer by: Favio Manriquez
Posted: Apr 29, 2013
Vote up!
0
Vote down!

Yeah, that youtube video helped a lot, I wasn't using the rules properly, once setting them it worked perfectly without a single line of custom code. Thanks a lot~!

Answer by: Ganzeiba
Posted: May 2, 2013