I have products with 2 prices, the Commerce default one commerce_price
, and a custom field field_price_with_flight
. In some cases, depending on the node display term value of a taxonomy, I need to calculate and display the discount prices onto the custom price instead of default Commerce price.
If it can be achieved with rules, I'd appreciate a detailed answer because I'm not very comfortable with the use of rules, especially commerce ones.
How could I achieve that ?
EDIT :
I need to make it possible through discount module UI. I'll try to expose why with the business model below.
The site sells travels. Anytime, depending on sales, the owner decides to create new discounts, with parameters such as:
- Limited time
- A different discount value usually fixed amount but could be % sometimes
- Applied on a selection of travels, choosed across discount UI whether per product or per category, with the help of Commerce Discount Product Category
The flexibility of Commerce Discount does the job most of the time. I could setup rules for one case, but this is just impossible to teach the site owner and sellers how to setup discount rules for each new one.
Now whenever you create a discount like that, The module creates a dedicated rule. Basic one exported below.
The challenge is that by default it will apply on commerce_price
. I need to extend Discount module so that :
- Or it detects the travel type has a field_price_with_flight value
- Or we tell the module it is that case with a checkbox in the discount form for instance
and applies then the discount to field_price_with_flight
.
Or, last, if possible, create a global rule that will overwrite each discount rule whenever necessary?
Basic rule created by discount
{ "commerce_discount_rule_discount_discount_example" : {
"LABEL" : "Discount example",
"PLUGIN" : "reaction rule",
"WEIGHT" : "-1",
"OWNER" : "rules",
"TAGS" : [ "Commerce Discount", "R\u00e9duction par produit" ],
"REQUIRES" : [
"commerce_discount",
"commerce_discount_date",
"commerce_product_reference"
],
"ON" : { "commerce_product_calculate_sell_price" : [] },
"IF" : [
{ "commerce_discount_compatibility_check" : {
"commerce_order" : [ "commerce-line-item:order" ],
"commerce_discount" : "discount_discount_example"
}
},
{ "commerce_discount_date_condition" : { "commerce_discount" : "discount_discount_example" } },
{ "commerce_product_contains_products" : { "sku" : "VE1201#2556#09-05-2016" } }
],
"DO" : [
{ "commerce_discount_fixed_amount" : {
"entity" : [ "commerce_line_item" ],
"commerce_discount" : "discount_discount_example"
}
}
]
}
}