Tags/topics: 
1
Answers
Vote up!
0
Vote down!

Pricing rule conditions---"Add or" breaks the rule. Bug or mistake?

I hope someone can tell me if this is a bug or if I'm making a mistake.
I am creating a pricing rule so that if product X, Y or Z is already in the cart, product A, B and C are discounted.

The following works as expected (note that there is only one condition and no disjunctions):

My event is: Calculate the sell price of a product.
My conditions: Order contains a particular product (Data selector: site:current-cart-order). I have input a SKU for product X.
For testing purposes, my Action is: Divide the unit price by some amount (I have it divided by 2). (Data selector: commerce-line-item; Price component type: Discount)

So when I put product X in the cart, the price of every other product is now displaying half of what it did prior to putting X in the cart. So far so good.

However, when I add a disjunction (an "or") to the conditions, the rule stops working. That is, even when X is in the cart, the price adjustment is not made to the other products. This happens if I simply click "Add or" and don't create any other condition, and it also happens if I click "Add or" and then create a condition under the "OR".

If "OR" works as a genuine disjunction, then it shouldn't matter what condition I put under the "OR", so long as the first disjunct is satisfied (the cart contains product X). The conditions should still evaluate to TRUE, and the pricing adjustment should still happen. Yet adding a disjunct breaks the pricing adjustment.

Help!

Thanks.

Asked by: deoanam2002
on July 10, 2012

Comments

1 Answer

Vote up!
0
Vote down!

It was my mistake. I was unable to find good documentation about how to use conditionals in rules, but I found something that made me realize I was using the OR group wrong.

I did this:
If product in cart is X
OR
product in cart is Y

It should have been:
OR
If product in cart is X
If product in cart is Y

Answer by: deoanam2002
Posted: Jul 11, 2012

Comments

Thank you! This solved my question which was related. On my products, customers can make modifications, such as adding a custom company name or color. We're using this (http://drupal.org/project/commerce_custom_product).

We charge a flat fee if the customer makes any modification. They can modify as much as they want, and it will still cost just that same flat fee. I needed to check if the entity had the fields, then check if the customer made any modification to the fields (using NOT Data Value is Empty).

So my rule is set up as:

Entity has Field (custom field #1)
Entity has Field (custom field #2)
OR
NOT Data value is empty (custom field #1)
NOT Data value is empty (custom field #2)

Now, if a user makes any modification at all to any field, they will be charged the flat fee.

I thought I would share my scenario if others were running into the same issue. Thanks again.

- trevorkjorlien on February 19, 2013