@@ -45,7 +45,8 @@ export default Component.extend(FormMixin, {
4545 accessCodeTickets : A ( ) ,
4646 discountedTickets : A ( ) ,
4747
48- invalidPromotionalCode : false ,
48+ invalidPromotionalAccessCode : false ,
49+ invalidPromotionalDiscountCode : false ,
4950
5051 tickets : computed ( 'orderAmount' , function ( ) {
5152 const ticketMap = { } ;
@@ -55,6 +56,11 @@ export default Component.extend(FormMixin, {
5556 } ) ;
5657 }
5758
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
5864 return this . data . sortBy ( 'position' ) . map ( ticket => {
5965 const ticketExtra = ticketMap [ ticket . id ] ;
6066
@@ -64,7 +70,7 @@ export default Component.extend(FormMixin, {
6470 }
6571
6672 return ticket ;
67- } ) ;
73+ } ) . concat ( this . accessCodeTickets ) ;
6874 } ) ,
6975
7076 hasTicketsInOrder : computed ( 'tickets.@each.orderQuantity' , function ( ) {
@@ -141,11 +147,11 @@ export default Component.extend(FormMixin, {
141147 ticket . set ( 'isHidden' , false ) ;
142148 this . tickets . addObject ( ticket ) ;
143149 this . accessCodeTickets . addObject ( ticket ) ;
144- this . set ( 'invalidPromotionalCode ' , false ) ;
150+ this . set ( 'invalidPromotionalAccessCode ' , false ) ;
145151 } ) ;
146152 } catch ( e ) {
147153 console . error ( 'Error while applying access code' , e ) ;
148- this . set ( 'invalidPromotionalCode ' , true ) ;
154+ this . set ( 'invalidPromotionalAccessCode ' , true ) ;
149155 }
150156 try {
151157 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, {
175181 ticket . set ( 'discountedTicketTax' , discountedTicket . discounted_tax ) ;
176182 ticket . set ( 'discount' , discountedTicket . discount . amount ) ;
177183 this . discountedTickets . addObject ( ticket ) ;
178- this . set ( 'invalidPromotionalCode ' , false ) ;
184+ this . set ( 'invalidPromotionalDiscountCode ' , false ) ;
179185 } ) ;
180186 } else {
181- this . set ( 'invalidPromotionalCode ' , true ) ;
187+ this . set ( 'invalidPromotionalDiscountCode ' , true ) ;
182188 }
183189 } catch ( e ) {
184190 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 ) ;
188192 }
189- if ( this . invalidPromotionalCode ) {
193+ // if both access code and discount code are invalid, warn
194+ if ( this . invalidPromotionalDiscountCode && this . invalidPromotionalAccessCode ) {
190195 this . set ( 'promotionalCodeApplied' , false ) ;
191196 this . notify . error ( this . l10n . t ( 'This Promotional Code is not valid' ) , {
192197 id : 'prom_inval'
0 commit comments