Allows you to change a Commerce Product price based on a secondary price field, if the user is authenticated.

Public

Rule for price calculation that allows you to substitute product price for member price.

Get raw version
text
  1. { "rules_commerce_set_product_price_trade_price" : {
  2. "LABEL" : "Commerce: set product price to trade price for authenticated users",
  3. "PLUGIN" : "reaction rule",
  4. "OWNER" : "rules",
  5. "REQUIRES" : [ "rules", "commerce_price", "commerce_product_reference" ],
  6. "ON" : { "commerce_product_calculate_sell_price" : [] },
  7. "IF" : [
  8. { "user_has_role" : {
  9. "account" : [ "site:current-user" ],
  10. "roles" : { "value" : { "2" : "2" } }
  11. }
  12. },
  13. { "entity_has_field" : { "entity" : [ "commerce-line-item" ], "field" : "commerce_product" } },
  14. { "entity_has_field" : {
  15. "entity" : [ "commerce-line-item:commerce-product" ],
  16. "field" : "field_trade_price"
  17. }
  18. },
  19. { "commerce_price_compare_price" : {
  20. "first_price" : [ "commerce-line-item:commerce-product:field-trade-price" ],
  21. "operator" : "\u003E",
  22. "second_price" : { "value" : { "amount" : 0, "currency_code" : "USD" } }
  23. }
  24. }
  25. ],
  26. "DO" : [
  27. { "data_set" : {
  28. "data" : [ "commerce-line-item:commerce-unit-price" ],
  29. "value" : [ "commerce-line-item:commerce-product:field-trade-price" ]
  30. }
  31. }
  32. ]
  33. }
  34. }