@@ -240,16 +240,24 @@ def create_order(form, from_organizer=False):
240240 discount = None
241241 if ticket_discount :
242242 discount = TicketingManager .get_discount_code (form .get ('event_id' ), form .get ('promo_code' ,'' ))
243- if not discount :
244- flash ('The promotional code entered is not valid. No offer has been applied to this order.' , 'danger' )
245- else :
243+ access_code = TicketingManager .get_access_code (form .get ('event_id' ), form .get ('promo_code' , '' ))
244+ if access_code and discount :
246245 order .discount_code = discount
247- flash ('The promotional code entered is valid.offer has been applied to this order.' , 'success' )
246+ flash ('Both access code and discount code has been applied. You can make this order now.' , 'success' )
247+ elif discount :
248+ order .discount_code = discount
249+ flash ('The promotional code entered is valid. Offer has been applied to this order.' , 'success' )
250+ elif access_code :
251+ flash ('Your access code is applied and you can make this order now.' , 'success' )
252+ else :
253+ flash ('The promotional code entered is not valid. No offer has been applied to this order.' , 'danger' )
254+
248255 ticket_subtotals = []
249256 if from_organizer :
250257 ticket_subtotals = form .getlist ('ticket_subtotals[]' )
251258
252259 amount = 0
260+ total_discount = 0
253261 fees = DataGetter .get_fee_settings_by_currency (DataGetter .get_event (order .event_id ).payment_currency )
254262 for index , id in enumerate (ticket_ids ):
255263 if not string_empty (id ) and int (ticket_quantity [index ]) > 0 :
@@ -262,6 +270,13 @@ def create_order(form, from_organizer=False):
262270 if from_organizer :
263271 amount += float (ticket_subtotals [index ])
264272 else :
273+ if discount and str (order_ticket .ticket .id ) in discount .tickets .split ("," ):
274+ if discount .type == "amount" :
275+ total_discount += discount .value * order_ticket .quantity
276+ else :
277+ total_discount += discount .value * order_ticket .ticket .price * \
278+ order_ticket .quantity / 100.0
279+
265280 if order_ticket .ticket .absorb_fees or not fees :
266281 amount += (order_ticket .ticket .price * order_ticket .quantity )
267282 else :
@@ -271,8 +286,8 @@ def create_order(form, from_organizer=False):
271286 else :
272287 amount += (order_ticket .ticket .price * order_ticket .quantity ) + order_fee
273288
274- if discount and discount . type == "amount" :
275- order .amount = max (amount - discount . value , 0 )
289+ if discount :
290+ order .amount = max (amount - total_discount , 0 )
276291 elif discount :
277292 order .amount = amount - (discount .value * amount / 100.0 )
278293 else :
0 commit comments