@@ -45,7 +45,8 @@ export default Component.extend(FormMixin, {
45
45
accessCodeTickets : A ( ) ,
46
46
discountedTickets : A ( ) ,
47
47
48
- invalidPromotionalCode : false ,
48
+ invalidPromotionalAccessCode : false ,
49
+ invalidPromotionalDiscountCode : false ,
49
50
50
51
tickets : computed ( 'orderAmount' , function ( ) {
51
52
const ticketMap = { } ;
@@ -55,6 +56,11 @@ export default Component.extend(FormMixin, {
55
56
} ) ;
56
57
}
57
58
59
+ // since this.data only contains the initial tickets
60
+ // we need to make sure that the tickets added via access code
61
+ // are added to the list.
62
+ // We do that below once with this.tickets.addObject(ticket),
63
+ // but this value will be overwritten here on recomputation
58
64
return this . data . sortBy ( 'position' ) . map ( ticket => {
59
65
const ticketExtra = ticketMap [ ticket . id ] ;
60
66
@@ -64,7 +70,7 @@ export default Component.extend(FormMixin, {
64
70
}
65
71
66
72
return ticket ;
67
- } ) ;
73
+ } ) . concat ( this . accessCodeTickets ) ;
68
74
} ) ,
69
75
70
76
hasTicketsInOrder :
computed ( '[email protected] ' , function ( ) {
@@ -141,11 +147,11 @@ export default Component.extend(FormMixin, {
141
147
ticket . set ( 'isHidden' , false ) ;
142
148
this . tickets . addObject ( ticket ) ;
143
149
this . accessCodeTickets . addObject ( ticket ) ;
144
- this . set ( 'invalidPromotionalCode ' , false ) ;
150
+ this . set ( 'invalidPromotionalAccessCode ' , false ) ;
145
151
} ) ;
146
152
} catch ( e ) {
147
153
console . error ( 'Error while applying access code' , e ) ;
148
- this . set ( 'invalidPromotionalCode ' , true ) ;
154
+ this . set ( 'invalidPromotionalAccessCode ' , true ) ;
149
155
}
150
156
try {
151
157
const discountCode = await this . store . queryRecord ( 'discount-code' , { eventIdentifier : this . event . id , code : this . promotionalCode , include : 'event,tickets' } ) ;
@@ -175,18 +181,17 @@ export default Component.extend(FormMixin, {
175
181
ticket . set ( 'discountedTicketTax' , discountedTicket . discounted_tax ) ;
176
182
ticket . set ( 'discount' , discountedTicket . discount . amount ) ;
177
183
this . discountedTickets . addObject ( ticket ) ;
178
- this . set ( 'invalidPromotionalCode ' , false ) ;
184
+ this . set ( 'invalidPromotionalDiscountCode ' , false ) ;
179
185
} ) ;
180
186
} else {
181
- this . set ( 'invalidPromotionalCode ' , true ) ;
187
+ this . set ( 'invalidPromotionalDiscountCode ' , true ) ;
182
188
}
183
189
} catch ( e ) {
184
190
console . error ( 'Error while applying discount code as promo code' , e ) ;
185
- if ( this . invalidPromotionalCode ) {
186
- this . set ( 'invalidPromotionalCode' , true ) ;
187
- }
191
+ this . set ( 'invalidPromotionalDiscountCode' , true ) ;
188
192
}
189
- if ( this . invalidPromotionalCode ) {
193
+ // if both access code and discount code are invalid, warn
194
+ if ( this . invalidPromotionalDiscountCode && this . invalidPromotionalAccessCode ) {
190
195
this . set ( 'promotionalCodeApplied' , false ) ;
191
196
this . notify . error ( this . l10n . t ( 'This Promotional Code is not valid' ) , {
192
197
id : 'prom_inval'
0 commit comments