Discounted price problem with Rules data selectors
The situation is the following:
There are two price fields for a product, and when my client fills out the second, it would be new discounted price. The page should display the old price crossed, and the new (the displaying not a problem).
Here is the problem:
I created a Rule that will only do an action when the second price field exists and is not empty. My only problem is that I can't set the price to the same amount the second price field has.
Does anyone know a solution, so I can set up an action that will set my price to a specific amount and that amount would be that the client wrote in the second price field?
Comments
Update main price from alternate field
I think what you want to do is to update the *main* price field from your alternate price field based on specific conditions.
Attached is a solution I just tried and it works fine. I created a price field on my product type called field_special_discount, and then created conditions that check:
* Is the line item of type product (brings the commerce_product into scope)
* Is the product type of type product (brings its fields into scope)
* Is the field_special_discount amount != 0
Then the action just sets the line item value of the *main* pricefield to that of the special discount field.
It works!!! There are no
It works!!! There are no words to describe how thankful I am right now!
This problem bugged me for over two weeks. I know I had to bring the product's fields into scope (from your screencast) but I could not manage to set it up right.
Thanks again, this was a HUGE help for me!
Update main price from alternate field - need help
I as very happy to see this post as I was have also been trying to get this to work for a while and was ready to post today. I was very close the same solution you have posted here. I am however, getting the same results with my "interpertation" of this solution. So hopefully someone can point out where I'm going wrong when I get stuck.
I am trying to do essentially the same. In a nutshell, on a "featured" page, I want to strike out the original price and show the new one, then have the new price applied to the cart as current.
I have:
- set a new field in my product type called "field_special_discount".
- Set the event to "Commerce Line item is viewed".
- Set the condition for :
Entity is of type
Parameter: Entity: [commerce-line-item], Entity type: Commerce Product
- Next, I was unable to find where to check if "Product Type" was of type Product. Product type does not show up in the entity list at the top of the page for data selectors.
- I also, possibly for the same reason, cannot find the "field_special_discount" reference in the entity list.
Are my "Events" maybe lacking an entry or have an incorrect one?
I have reviewed as much Rules documentation/videos as I can, most of it covers percentages and I have also been back through The Definitive Guide to Drupal 7 for advice. Can anyone see what I might have gotten wrong here please?
Thank you,
Use a product pricing rule
Use a product pricing rule, just as in the example above. Your event will be "Calculating the sell price of a product". All the work of presenting the display is done there for you.
Use a product pricing rule
I imported the rule you created. I wasn't too sure where to do that at first, hence the wait. With that the issue became clearer. I then recreated the rule just to see how it was done.
I was always using the "Entity is of type" and never thought of it as a Data comparison for a type. I was possibly making other mistakes with the selector itself to compound it.
I am not completely clear on the appropriate choices available in Rules yet, but this helps me see where I went off the track. I can review the docs/videos again and hopefully figure out what points I missed.
Thank you very much, you're awesome!
Further suggested reading is welcome btw,in case I missed a good one...;-)
nodeone.se have something
nodeone.se have something like, over 30 video tutorials on rules for Drupal 7. Well worthwhile. If you go back something like 7-12 pages in the pagination on Vimeo you will find them.
http://vimeo.com/nodeone
Official link to nodeone rules videos
The official link to the nodeone.se rules series is http://dev.nodeone.se/en/learn-the-rules-framework - They're also on on drupalize.me (free).
Entity is of type versus using a data comparison
My main point of confusion here is to why a data comparison is used instead of "entity is of type". I'm reviewing more basic docs for D7 again to see where my thinking went wrong.
Definitely the original post works great. Thank you so much. Drupal Commerce is very much worth any learning curves.
Thanks again,
Entity type vs bundle
"Entity is of type" actually checks the *entity type*, not the *bundle* if I'm not mistaken. So with a commerce line item, you'd be asking "Is this entity a commerce line item" instead of what you do with a data comparison on 'type', which asks "Is this commerce line item a line item of bundle 'product'".
RE: Entity type vs bundle
Thank you very much, that does clarify it and explains it's behaviour when I was doing that wrong.
Where is the attached rule?
Where is the attached rule?
I'm trying to do the 3rd step "Is the field_special_discount amount != 0" but i can't bring the "field_special_discount" to the scope!
Thanks!
forget about it...
forget about it...
i started again, added "entity has field condition" and i found the field in: commerce-line-item:commerce-product:field-special-discount
instead of define the new
instead of define the new price in the field, can we define the percentage discount in the field?
i.e.: in the field_special_discount i enter "25" and in the action the price will be 25% lower.
it's possible?
thanks!