Vote up!
Vote down!

commerce-product:type data selector missing in rules conditions

I'm trying to set up a rule to use a specific payment method for a specific product type. I have the default "product" and a type I added called "download." In my rule, I'm trying to add a data data comparison rule to determine the product type, but "commerce-product:" is not available. The only selectors available are "site:" and "commerce-order:" Is there a way to expose commerce-product:type?

Asked by: eorr
on October 3, 2012

2 Answers

Vote up!
Vote down!

In order to get at the product types on the order, you have to look inside the commerce-order token at the line items it contains. Specifically, in your actions section you can loop over the commerce-order:commerce-line-items token and pass each individual line item to a separate rules component that checks the type of the referenced product and then enables the payment method if necessary.

To truly prototype this, we would need to know your site setup - for example, can the user ever have more than one product in the cart, and if so might they differ in which payment method applies to them? How would you handle such a conflict?

If you're only allowing one product in the cart at the time or can trust products in the cart to always use the same payment method, your other option besides using the loop on commerce-order:commerce-line-items would be to use the condition we provide titled Order contains a particular product, which has the ability to look for particular SKUs inside the line items without depending on a secondary rules component. Very handy.

Ryan Szrama
Answer by: Ryan Szrama
Posted: Nov 3, 2012


But if I add a payment method and I add the loop, a error message appears in payment method page.

- Derio on December 18, 2013

I want to give a role based discount of 30% which I have successfully configured EXCEPT I need to exclude certain product types (student fees), which I have tried to do by

NOT Order contains a particular product
Parameter: Order: [commerce-line-item:order], Product SKU: FEE-DUES-ANN ..

Do I need to create a separate condition for each SKU? I listed them each on a different line, i.e.


Or do I need a loop? Still barely getting to know Commerce.

- svn7svn on April 11, 2014
Vote up!
Vote down!

Hi to all... great Drupal Commerce V 2... but...

How can I refund only one item in an order with 2 or more items?

If I am using commerce Reverse Payment and Stock modules, how can I add back to the stock field when the transaction is completed?

Thanks again

Answer by: rgarneau
Posted: Nov 27, 2012