2

I'm using Drupal 7 and Commerce. We have several product displays: Caramel, Chocolate, Cinnamon, Cheddar, etc. Each of these product displays has 5 SKUs (5 products) for the 5 different sizes we offer. Each product display also gets tagged as either "premium" or "standard."

I'm trying to then build a "sampler" where they choose up to three of those flavors. To do this, I'm using an entity reference field so that that list always has the current flavors. i.e. If they had Hazelnut, the sampler gets updated with Hazelnut.

If they choose a premium flavor, it should add $5 to the total price per premium flavor, but if there are no premium flavors, then it should stay the same price.

I have a rule set up that is halfway there. Problem is, if there is even just one premium flavor, it charges $5 per item checked, regardless of whether they're premium or standard.

I can't figure out how to only apply the upcharge per premium flavor. Any help is greatly appreciated. Willing to help fund this some if needed.

0

The first (crucial) part of your rule is a Rules Action to perform a Loop. If you're not familiar with such loops, then I strongly recommend to have a look at the tutorial titled "Lists and loops".

So add a loop related to the flavors that got selected. After you do, you should iterate over each item in that list (= each flavor).

And for each iteration you should then perform an appropriate verification if it is a premium flavor (in which case you want to add $5). But, within Rules Actions, you cannot just add another Rules Condition (as you may have noticed) ... Except if you use the Conditional Rules module (which is exactly the purpose of this module ...).

Done

PS: are those funds still available?

  • Thanks, Pierre. This question was from 5 years ago and I ended up finding a different method for achieving the same task. Thanks for the answer! – MrPeanut Feb 16 '17 at 13:58
  • @MrPeanut : merci for the comment. But even though your question is from "some" time ago, it kept showing up in the list of unanswered questions. If you want to consider doing so (and only then), it would start showing as "answered" instead if you think my answer is "good enough" to mark it as accepted ... Ps: with no need for any "funds" either ... – Pierre.Vriens Feb 16 '17 at 14:04

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.