|
42 | 42 | WidgetCode.addPoints = function () { |
43 | 43 | var success = function (result) { |
44 | 44 | Buildfire.spinner.hide(); |
45 | | - $rootScope.$broadcast('POINTS_ADDED', {points: (currentView.amount * WidgetCode.application.pointsPerDollar) + WidgetCode.application.pointsPerVisit}); |
46 | | - var pointsAwarded = (currentView.amount * WidgetCode.application.pointsPerDollar) + WidgetCode.application.pointsPerVisit; |
| 45 | + var pointsAwarded |
| 46 | + var purchaseOptionValue = WidgetCode.application.settings.value; |
| 47 | + if(purchaseOptionValue === 'perMoneySpent'){ |
| 48 | + $rootScope.$broadcast('POINTS_ADDED', {points: (currentView.amount * WidgetCode.application.pointsPerDollar) + WidgetCode.application.pointsPerVisit}); |
| 49 | + pointsAwarded = (currentView.amount * WidgetCode.application.pointsPerDollar) + WidgetCode.application.pointsPerVisit; |
| 50 | + } |
| 51 | + else { |
| 52 | + $rootScope.$broadcast('POINTS_ADDED', {points: currentView.amount + WidgetCode.application.pointsPerVisit}); |
| 53 | + pointsAwarded = currentView.amount + WidgetCode.application.pointsPerVisit; |
| 54 | + } |
47 | 55 | ViewStack.push({ |
48 | 56 | template: 'Awarded', |
49 | 57 | pointsAwarded: pointsAwarded |
|
70 | 78 |
|
71 | 79 | }; |
72 | 80 | Buildfire.spinner.show(); |
73 | | - checkIfUserDailyLimitExceeded(currentView, WidgetCode, function (err, res) { |
| 81 | + var purchaseOptionValue = WidgetCode.application.settings.value; |
| 82 | + checkIfUserDailyLimitExceeded(currentView, WidgetCode, purchaseOptionValue, function (err, res) { |
74 | 83 | if (err) return error(err); |
75 | 84 | buildfire.auth.getCurrentUser(function (err, user) { |
76 | 85 | if (user) { |
|
123 | 132 | } |
124 | 133 |
|
125 | 134 | } else { |
126 | | - LoyaltyAPI.addLoyaltyPoints(WidgetCode.currentLoggedInUser._id, WidgetCode.currentLoggedInUser.userToken, `${WidgetCode.context.appId}_${WidgetCode.context.instanceId}`, WidgetCode.passcode, currentView.amount).then(success, error); |
| 135 | + LoyaltyAPI.addLoyaltyPoints(WidgetCode.currentLoggedInUser._id, WidgetCode.currentLoggedInUser.userToken, `${WidgetCode.context.appId}_${WidgetCode.context.instanceId}`, WidgetCode.passcode, currentView.amount, res.data.pointsAwarded |
| 136 | + ).then(success, error); |
127 | 137 | } |
128 | 138 | } |
129 | 139 | }) |
|
0 commit comments