3

In Drupal Commerce, when you create a tax rate of a particular type, let's say a "VAT low" of type VAT, a rule "Calculate taxes: VAT" is created, as well as a rule component "Calculate VAT Low".

Now I want to make the "Calculate VAT Low" component conditional on the product type of the product referenced in the line item. The examples for conditions in the tax component that I found, however, use data selectors of the order like address, not a line item. Other examples of using conditions based on the product type referenced by the line item are configured at the level of the rule, not the component (e.g. here). The commerce-line-item:commerce-product:type does not seem to be available when adding conditions to a component.

Is it possible to make tax components conditional on the product type of the line item? Or should I create a separate rule for each tax rate component rather than use the default "Calculate taxes: VAT"?

1 Answer 1

1

I found out how to use product type as a condition - it actually does work the same for rules and rules components.

When I tested this, I was adding the condition "Entity has field": field_product, but in order for the commerce-line-item:commerce-product:type data selector to appear under the Data comparison condition, you have to use the field commerce_product, which is the product reference field used on the line-item entity.

1
  • I cannot figure out how to get the line-item:commerce-product:type from within an action loop. Did you find any useful documentation for accessing line item product types? Sep 7, 2017 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.