I think I found a bug. The patch below is an attempt at fixing it.
Goal: Permit registrants to apply a discount code to each member in a group registration.
Settings:
Discount Codes - Discount Type: Item price
Discount Codes - Active in Registration Types: Both
Discount Codes - Active in Group Registrations For: Members & Billing
Discount Codes - Minimum Group Size: 0
Event - Discounts & Fees - Use Discount Code: Yes (Optional)
Event - Discounts & Fees - Group Registration Code Display: Each Member
Expected result: When a user enters a permitted discount code, there should be no validation error.
Actual result: When a user enters a permitted discount code,
- the following JSON is returned from the server:
{"status":"This code is not valid for this type of registration.","discount_code_id":false,"fields":[]}
- the following validation error displays in the HTML:
Invalid field: Discount Code
The following patch prevents the validation errors from displaying in this case:
Author: Tim Black <tim@alwaysreformed.com> 2019-08-26 22:02:50
Committer: Tim Black <tim@alwaysreformed.com> 2019-08-26 22:02:50
Parent: 774ad4e03c6dfab934c318de4360bc0dde361c68 (fix(class.listype): fix blank page in JNews by initializing array correctly)
Branches: master, remotes/origin/master
Follows:
Precedes:
fix(devent): permit discount code to be used in group registrations
It appears there was a bug here, because configuring DT Register correctly
didn't permit discount codes to be used in group registrations. This is an
attempt to fix that bug.
---------- administrator/components/com_dtregister/models/devent.php ----------
index 97d040ee2..3ad19b11d 100644
@@ -2289,7 +2289,7 @@ class DtrTableDevent extends DtrTable
}
} else {
- if ($this->use_discountcode && in_array($this->discount_code_usagetype, array(2, 3))) { } else {
+ if ($this->use_discountcode && in_array($this->discount_code_usagetype, array(1, 2, 3))) { } else {
$dt_code->error = JText::_('DT_CODE_NOT_REG_TYPE');
So far as I could see, the meaning of the 1, 2, 3
values is not documented in the code, so this patch may not be the right way to fix the problem. However, it appears to me that without this patch, there may still be a bug in the code.
If instead I have just failed to configure the discount code settings correctly in DT Register, please let me know the right settings to use to accomplish the goal.
I did not provide the site URL, admin account, or FTP info above, but can provide them if you need them.
Thank you!
Tim