ANSWERED
ANSWERED
ANSWERED

Extension >Reward Point Loyalty Program Solution

Justin was asked for a solution on a loyalty program, where an associate would receive reward points based on the length of time someone remained on Autoship. This is a solution Justin provided to the development team: #Notes: - Reward Points will be distributed to associate types 1 & 3 on all autoship orders based on the rules outlined below. - The first successful autoship processed is month 1 and will receive 5% of the order subtotal as reward points. Months 1-3 receive 5%, months 4-12 receive 10%, and 13+ months receive 15%. - The points will not be tied to a specific autoship ID but if the user has an active autoship order every month. We will use the Associate Custom fields to keep track of successful autoship orders as well as the length of consecutive successful autoship orders. - If the user cancels their autoship and does not have another active autoship (not an annual renewal) their points balance will be removed. - If the user fails to pay for an autoship order for a month, their reward points will remain on the account and the accumulated months will remain the same until the autoship is cancelled. Autoship retry rules will be reevaluated to account for this use case. - Once the autoship is paid for after failing for more than one month, the count of months on autoship will continue where it left off. I.e. If the autoship processes successfully in July on month 3 then fails in August and September, when it processes successfully in October it will increase to month 4. - If there is more than 1 successful autoship processed in the month, each order will earn reward points but the percentage increase will only happen monthly. - To keep track of the months as well as the last successful autoship order, the Associate Custom fields will be used. 1. CRM_CustomFields Field1 will be the last successful autoship month (mm/yyyy) 2. CRM_CustomFields Field2 will be the number of months on autoship >A query will need to run to update all existing Associates (Type 1 or 3) with the correct data in CRM_CustomFields Field1 and Field 2 before rolling live. The query will need to be written to match the criteria below to update all existing associates who have been on autoship with the correct last processed month (Field1) and consecutive months on autoship (Field2). ##The developer will need to program the following: ###In the FinalizeAcceptedOrder Hook: 1. Check for OrderType=2 and AutoShipType is 0 or 1 2. Check for AssociateType 1 or 3 3. Get CRM_CustomFields 4. Check Field1 to see if value is any month prior to the current month, if it is Update Field2 +1 else if Field1 != current month, Update Field2 = 1 >// Note: if Field1 = current month, no changes to Field2 ###Update CRM_CustomFields Field1 - Field1= current month (mm/yyyy) - Distribute the points based on the rules - CRM_CustomFields Field2 contains the number of months 1. 1-3 = 5% of Order SubTotal 2. 4-12 = 10% of Order SubTotal 3. 13+ = 15% of Order SubTotal - Use IRewardPointsService from DirectScale NuGet package to add points ###In the CancelAutoship Hook: - Check to see if there are other valid autoships (only AutoShipType 0 or 1). If there are no other valid autoships, - Get RemainingBalance total from CRM_RewardPoints - Create an entry in that is the negative of the total RemainingBalance - Use IRewardPointsService from DirectScale NuGet package to add negative points - Update CRM_CustomFields 1 & 2 back to blank - CRM_CustomFields Field1 = "" - CRM_CustomFields Field2 = ""