Vote up!
Vote down!

How do I determine the product type in a product pricing rule?

I have two price fields on my product type:

  1. commerce default price field
  2. buyin price

Now i'm trying to create a rule that does the following:

After saving/updating a product

Has fields 1 & 2
Product is of variation type

Set data value (my calculation)

The part "Product is of variation type" is what I cannot figure out. Any suggestions?

Asked by: easycombvba
on July 19, 2013

1 Answer

Vote up!
Vote down!

First you need to consider how you'll access the product data. Since product pricing rules receive a product line item as a default parameter, you can get to the product on the line item via its product reference field. This means you first need to use an Entity has field condition on the line item looking for commerce_product. Then you can use the Data comparison condition to evaluate the type of the product using the data selector commerce-line-item:commerce-product:type.

In Commerce Kickstart, we refer to the individual product entities referenced by a product display node the "variations" of the product, because a multi-value reference typically represents variations amongst a group of products. From a data standpoint, though, you're just dealing with products, which is why you won't see the word "variation" in the selector.

Ryan Szrama
Answer by: Ryan Szrama
Posted: Jul 19, 2013