Discussions

Fixed Price Discounting

Hi

I have been trying to figure this out for some-time,

Here is the scenario:

I have bunch of products unit which I would like to apply a fixed value discount too and only to certain products and the value of the discount can change between products.
The goal is using the commerce_extra_price_formatters to display a product example
Normal Unit Price : $100
Discounted Price : $80
You Save : $20

In the Product type I have created a field "field_discount" and a corresponding line item its a price field with the currency. Now using rules I would like to subtract the discount field value from the unit price.

I have setup a pricing rule "Fixed Price Discount" and have set a condition to check for the field entity (so its available in the actions) (I had added a second condition to check the discount field wasn't empty or something but that worked OK so I removed for now).
And I Added the action for subtracting an amount from the unit price the amount being a data entity for the discount field.

I have turned on the Rules Evaluation log (for debugging)
Now when I view the product on the front end and check the event log for this rule I get something like this :

    0 ms Rule Fixed Discount fires.
    4.293 ms Unable to apply data selector commerce-line-item:field-discount:amount: Unable to get the data property amount as the parent data structure is not set.
    6.957 ms Unable to evaluate action commerce_line_item_unit_price_subtract.
    7.014 ms Rule Fixed Discount has fired.

I have no idea what I should be setting in order to find "parent data structure"

The other discount rules types work for % percentage discounts and so on but I can't seem to find documentation for this type of scenario and its definitely a useful feature which I wouldn't have thought hard to set-up... has anyone any ideas for me to try?

Posted: Sep 22, 2011

Comments