Hi,

Great job on this module. I'm not sure if this is the place to be asking this but here goes:

I'm using this great module on a project and need to limit the contribution amount to a maximum of $300 but I can't seem to figure out what rule to create that checks against this value.

I'm trying to modify the included rule "Disallow too big contributions" but can't wrap my head around all the data selectors. Any idea what I should be looking at?

Thank ya!

Comments

maciej.zgadzaj’s picture

Talking about "contribution amount" you mean the max amount for a single project, or max amount of a single contribution (from one person)?

mfarha’s picture

Hey thanks for the reply, much appreciated.

The "contribution amount" I meant is the actual amount that a user can submit. Say I need to raise $1000 for someone, I want to actually limit each contribution a user can pay to a maximum of $300, so If they try to pay more than that than it automatically adjusts it to $300 and gives them a message.

Is that clearer now?

Thanks again.

maciej.zgadzaj’s picture

Status: Active » Fixed

If you don't want to play with form altering, adding own validation function and verifying the contribution amount there, you could always use a rule similar to this one:

{ "rules_limit_contribution_amount" : {
    "LABEL" : "Limit contribution amount",
    "PLUGIN" : "reaction rule",
    "TAGS" : [ "Commerce Contribution" ],
    "REQUIRES" : [ "rules", "commerce_cart" ],
    "ON" : [ "commerce_cart_product_add" ],
    "IF" : [
      { "entity_has_field" : { "entity" : [ "commerce-line-item" ], "field" : "commerce_product" } },
      { "data_is" : { "data" : [ "commerce-line-item:type" ], "value" : "contribution" } },
      { "data_is" : {
          "data" : [ "commerce-line-item:field-contribution-amount:amount" ],
          "op" : "\u003E",
          "value" : "30000"
        }
      }
    ],
    "DO" : [
      { "data_set" : {
          "data" : [ "commerce-line-item:field-contribution-amount:amount" ],
          "value" : "30000"
        }
      },
      { "drupal_message" : {
          "message" : "You can\u0027t contribute more that 300. Your contribution amount has been adjusted.",
          "type" : "warning"
        }
      }
    ]
  }
}

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.