@@ -39,9 +39,26 @@ export default Component.extend(FormMixin, {
3939
4040 invalidPromotionalCode : false ,
4141
42- tickets : computed ( function ( ) {
43- return this . data . sortBy ( 'position' ) ;
42+ tickets : computed ( 'orderAmount' , function ( ) {
43+ const ticketMap = { } ;
44+ if ( this . orderAmount ) {
45+ this . orderAmount . tickets . forEach ( ticket => {
46+ ticketMap [ ticket . id ] = ticket ;
47+ } ) ;
48+ }
49+
50+ return this . data . sortBy ( 'position' ) . map ( ticket => {
51+ const ticketExtra = ticketMap [ ticket . id ] ;
52+
53+ if ( ticketExtra ) {
54+ ticket . set ( 'subTotal' , ticketExtra . sub_total ) ;
55+ ticket . set ( 'discountInfo' , ticketExtra . discount ) ;
56+ }
57+
58+ return ticket ;
59+ } ) ;
4460 } ) ,
61+
4562 hasTicketsInOrder :
computed ( '[email protected] ' , function ( ) { 4663 return sumBy ( this . tickets . toArray ( ) ,
4764 ticket => ( ticket . orderQuantity || 0 )
@@ -103,7 +120,6 @@ export default Component.extend(FormMixin, {
103120 this . tickets . removeObject ( ticket ) ;
104121 } ) ;
105122 this . discountedTickets . forEach ( ticket => {
106- let taxRate = ticket . get ( 'event.tax.rate' ) ;
107123 ticket . set ( 'discount' , 0 ) ;
108124 } ) ;
109125 this . accessCodeTickets . clear ( ) ;
@@ -164,8 +180,9 @@ export default Component.extend(FormMixin, {
164180 this . set ( 'promotionalCode' , 'Promotional code applied successfully' ) ;
165181 }
166182 this . order . set ( 'amount' , this . total ) ;
167-
183+ this . send ( 'updateOrderAmount' ) ;
168184 } ,
185+
169186 async updateOrder ( ticket , count ) {
170187 ticket . set ( 'orderQuantity' , count ) ;
171188 this . order . set ( 'amount' , this . total ) ;
@@ -179,8 +196,15 @@ export default Component.extend(FormMixin, {
179196 this . order . tickets . removeObject ( ticket ) ;
180197 }
181198 }
199+
200+ this . send ( 'updateOrderAmount' ) ;
201+ } ,
202+
203+ async updateOrderAmount ( ) {
182204 console . log ( this . orderAmountInput ) ;
183- this . orderAmount = await this . loader . post ( '/orders/calculate-amount' , this . orderAmountInput ) ;
205+
206+ this . set ( 'orderAmount' , await this . loader . post ( '/orders/calculate-amount' , this . orderAmountInput ) ) ;
207+
184208 console . log ( this . orderAmount ) ;
185209 } ,
186210
0 commit comments