Bug: Auto discounts not working for membership
Created by: chamilwijesooriya
Auto discounts feature is not working for memberships.
- CiviDiscount 3.3
- CiviCRM 5.1.1
- Auto populated with default civi data
Steps to reproduce:
- Create a new discount
- Add a single membership type
- In Automatic Discounts section enter the following: Entity : Contact API String: {"custom_2":"Single"}
- Save
- Go to a any contact that has Marital Status as Single
- Goto Memberships -> Add Membership
- Choose the relevant membership type
- Verify bug
NB: custom_2 is Marital Status under Constituent Information
Possible Solution: In line 583 of cividiscount.php (cividiscount_civicrm_membershipTypeValue) (v3.3), change:
if (!empty($code)) {
$discounts = $discountCalculator->getDiscounts();
}
to:
$discounts = $discountCalculator->getDiscounts();
if (empty($code))
$discounts = $discountCalculator->autoDiscounts;