@@ -322,55 +322,53 @@ $(function() {
322
322
} ,
323
323
preApplyDiscount : function ( discount_coupons ) {
324
324
//Ask server for the corresponding line_item for the discount coupon. Add one quantity of that line_item
325
- if ( boxoffice . ractive . get ( 'order.line_items' ) > 0 ) {
326
- $ . post ( {
327
- url : boxoffice . config . resources . kharcha . urlFor ( ) ,
328
- crossDomain : true ,
329
- dataType : 'json' ,
330
- headers : { 'X-Requested-With' : 'XMLHttpRequest' } ,
331
- contentType : 'application/json' ,
332
- data : JSON . stringify ( {
333
- line_items : boxoffice . ractive . get ( 'order.line_items' ) . map ( function ( line_item ) {
334
- return {
335
- quantity : 1 ,
336
- item_id : line_item . item_id
337
- } ;
338
- } ) ,
339
- discount_coupons : discount_coupons
325
+ $ . post ( {
326
+ url : boxoffice . config . resources . kharcha . urlFor ( ) ,
327
+ crossDomain : true ,
328
+ dataType : 'json' ,
329
+ headers : { 'X-Requested-With' : 'XMLHttpRequest' } ,
330
+ contentType : 'application/json' ,
331
+ data : JSON . stringify ( {
332
+ line_items : boxoffice . ractive . get ( 'order.line_items' ) . map ( function ( line_item ) {
333
+ return {
334
+ quantity : 1 ,
335
+ item_id : line_item . item_id
336
+ } ;
340
337
} ) ,
341
- timeout : 5000 ,
342
- retries : 5 ,
343
- retryInterval : 5000 ,
344
- success : function ( data ) {
345
- var discount_applicable = false ;
346
- var line_items = boxoffice . ractive . get ( 'order.line_items' ) ;
347
- line_items . forEach ( function ( line_item ) {
348
- if ( data . line_items . hasOwnProperty ( line_item . item_id ) ) {
349
- if ( data . line_items [ line_item . item_id ] . discounted_amount && line_item . quantity_available > 0 ) {
350
- discount_applicable = true ;
351
- line_item . unit_final_amount = data . line_items [ line_item . item_id ] . final_amount ;
352
- line_item . discount_policies . forEach ( function ( discount_policy ) {
353
- if ( data . line_items [ line_item . item_id ] . discount_policy_ids . indexOf ( discount_policy . id ) >= 0 ) {
354
- discount_policy . pre_applied = true ;
355
- }
356
- } ) ;
357
- }
338
+ discount_coupons : discount_coupons
339
+ } ) ,
340
+ timeout : 5000 ,
341
+ retries : 5 ,
342
+ retryInterval : 5000 ,
343
+ success : function ( data ) {
344
+ var discount_applicable = false ;
345
+ var line_items = boxoffice . ractive . get ( 'order.line_items' ) ;
346
+ line_items . forEach ( function ( line_item ) {
347
+ if ( data . line_items . hasOwnProperty ( line_item . item_id ) ) {
348
+ if ( data . line_items [ line_item . item_id ] . discounted_amount && line_item . quantity_available > 0 ) {
349
+ discount_applicable = true ;
350
+ line_item . unit_final_amount = data . line_items [ line_item . item_id ] . final_amount ;
351
+ line_item . discount_policies . forEach ( function ( discount_policy ) {
352
+ if ( data . line_items [ line_item . item_id ] . discount_policy_ids . indexOf ( discount_policy . id ) >= 0 ) {
353
+ discount_policy . pre_applied = true ;
354
+ }
355
+ } ) ;
358
356
}
359
- } ) ;
360
-
361
- if ( discount_applicable ) {
362
- boxoffice . ractive . set ( 'order.line_items' , line_items ) ;
363
- // Scroll to the top of the widget when a discount is pre-applied
364
- boxoffice . ractive . scrollTop ( ) ;
365
357
}
366
- } ,
367
- error : function ( response ) {
368
- var ajaxLoad = this ;
369
- ajaxLoad . retries -= 1 ;
370
- boxoffice . ractive . xhrRetry ( ajaxLoad , response ) ;
358
+ } ) ;
359
+
360
+ if ( discount_applicable ) {
361
+ boxoffice . ractive . set ( 'order.line_items' , line_items ) ;
362
+ // Scroll to the top of the widget when a discount is pre-applied
363
+ boxoffice . ractive . scrollTop ( ) ;
371
364
}
372
- } ) ;
373
- }
365
+ } ,
366
+ error : function ( response ) {
367
+ var ajaxLoad = this ;
368
+ ajaxLoad . retries -= 1 ;
369
+ boxoffice . ractive . xhrRetry ( ajaxLoad , response ) ;
370
+ }
371
+ } ) ;
374
372
} ,
375
373
updateOrder : function ( event , item_name , quantityAvailable , increment ) {
376
374
// Increments or decrements a line item's quantity
0 commit comments