Recently, I wanted to do rule-based pricing in Drupal Commerce, but only for a certain product type. Commerce ships with a rule to react on “Calculating the Sell Price of a Product” and an associated set of actions to discount by a percentage (10% off!), fixed amount ($10 off!), or set a fixed price (only $10!).
This is what you’ll typically find documented, but I got tripped up trying to add a condition to only apply a discount to certain product types instead of globally discounting products (all square widgets only $10!). By default, though, I wasn’t able to use the line item’s product type in a data comparison condition.
Turns out you can do this, but, as is so often the case, you need to figure out what magical incantation will give you the rules scope you need. In this case, adding an “Entity has field” condition to check that the entity has the ‘commerce_product’ field does the trick. From there, you’ll be able to add another condition and reference the commerce-line-item:commerce-product: selector to do your comparison.
Update: I’ve posted a sample rule for those who would like to see a complete implementation.