I want to give a specific user a price override on specific products. In doing so, I added field collection on the people account setting. This field collection has to two fields: product sku and price.
I also created a rule with this codes:
{ "rules_price_override" : {
"LABEL" : "price override",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "commerce_line_item", "commerce_product_reference" ],
"ON" : { "commerce_product_calculate_sell_price" : [] },
"IF" : [
{ "user_has_role" : {
"account" : [ "site:current-user" ],
"roles" : { "value" : { "2" : "2" } }
}
},
{ "entity_has_field" : { "entity" : [ "commerce-line-item" ], "field" : "commerce_product" } },
{ "entity_has_field" : {
"entity" : [ "site:current-user:field-price-override:0" ],
"field" : "field_product_sku"
}
},
{ "data_is" : {
"data" : [ "site:current-user:field-price-override:0:field-product-sku" ],
"value" : [ "commerce-line-item:commerce-product:sku" ]
}
}
],
"DO" : [
{ "commerce_line_item_unit_price_amount" : {
"commerce_line_item" : [ "commerce_line_item" ],
"amount" : [ "site:current-user:field-price-override:0:field-regular-price:amount" ],
"component_name" : "base_price",
"round_mode" : "1"
}
}
]
}
}
But it only good for the first field collection value.
What will be the best way to make it loop, so that it can change its index as site:current-user:field-price-override:0 - end