1

I have to aplly a custom fee if in the cart there's a product with a certain value for a field (producs with particular kind of battery). I use Commerce fees for applying the fee.

Every time the cart is updated I have to check: if there is at least one of those products the fee is applyed; if there's not (or there's not anymore) I have to not apply or remove the fee.

Removing a fee is a problem, as the module doesn't allow this. But the bigger problem is whith rules: in conditions I can look for a particular SKU (only one) or a particular content type; instead I have to check something like this: "if there's in cart at least one product whith the value 1 for the field_battery,..."

Field_battery is a boolean field thath allow to the store's owner to flag products whith particulr battery, that require the extra fee.

I'm trying with the event "After updating an existing ordine commerce" btu I need help for conditions...

Thanks.

1

Not sure if this is the best way, but its the only way I can think of to do it.

You can do this by adding 3 different rules as well as adding a new field to "order" at admin/commerce/config/order/fields. We will call the field "Apply Fee" (apply_fee) and it is of the field type "integer"

Rule # 1, Event: when product added to cart
Condition: Entity has field: Entity=order Field=Apply_Fee
Action: Set Data Value: (use the data selecter to slect the "apply_fee" field) add offset "1"

Rule # 2, Event: when product removed from cart
Condition: Entity has field: Entity=order Field=Apply_Fee
Action: Set Data Value: (use the data selecter to slect the "apply_fee" field) add offset "-1"

Rule # 3, Event: Apply fee to order
Condition: Entity has field: Entity=order Field=Apply Fee
Condition: Data Comparison: order's field Apply Fee is Greater than 0
Action: Apply a Fee to order

0

You can have a Rule that looks for a SKU, a partial SKU or a Product Type using the module Commerce Rules Extra.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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