hello
I'm trying to apply a tax depending on a custom field into a product.
I've added the custom field to the product and setted the rule as described in documentation by adding "entity is of type" and "entity has field". My custom field is not appearing and I've decided to apply the tax programatically (to meet my needed conditions) . I've followed http://drupal.stackexchange.com/questions/3737/programmatically-execute-... and lot of pages trough google search.

I've created several rules components and used rules_invoke_component and rules_invoke_event as described in docs.

Could you give me a clue/hand/help on apply a tax or not to line item depending on a custom field into product entity?

Thank you.

Comments

bojanz’s picture

Status: Active » Fixed

You get a line item in the component.
First do an "entity has field" condition on commerce-line-item:commerce-product. This will make the product show up.
Then do an "entity has field" condition on the custom product field, passing the product that is now available. This will make the field show up.
Then do whatever you want :) Just make sure any other conditions come after these two.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

tahiticlic’s picture

Hi, Bojanz can you explain in which component you can set the commerce-line-item:commerce-product condition ?

I've got two VAT rates, and in component conditions, I cannot select commerce-line-item:commerce-product all I have is commerce-line-item:order stuff, and that doesn't help in order to set a condition on a product field.

[Edit] Okay, I've found this video http://vimeo.com/29725767, I was looking in the wrong selector...