def use_coupon_code(coupons, user):
 cart = Order.get_cart_for_user(user)
 cart_items = cart.orderitem_set.all().select_subclasses()
 is_redemption_applied = False
 for coupon in coupons:
  try:
   if CouponRedemption.add_coupon_redemption(coupon, cart, cart_items):
    is_redemption_applied = True
  except MultipleCouponsNotAllowedException:
   return HttpResponseBadRequest(_('Only one coupon redemption is allowed against an order'))
 if (not is_redemption_applied):
  log.warning(u"Discount does not exist against code '%s'.", coupons[0].code)
  return HttpResponseNotFound(_("Discount does not exist against code '{code}'.").format(code=coupons[0].code))
 return HttpResponse(json.dumps({'response': 'success', 'coupon_code_applied': True}), content_type='application/json')

def use_coupon_code ( coupons , user ) : cart = Order . get_cart_for_user ( user ) cart_items = cart . orderitem_set . all ( ) . select_subclasses ( ) is_redemption_applied = False for coupon in coupons : try : if CouponRedemption . add_coupon_redemption ( coupon , cart , cart_items ) : is_redemption_applied = True except MultipleCouponsNotAllowedException : return HttpResponseBadRequest ( _ ( 'Only one coupon redemption is allowed against an order' ) ) if ( not is_redemption_applied ) : log . warning ( u"Discount does not exist against code '%s'." , coupons [ 0 ] . code ) return HttpResponseNotFound ( _ ( "Discount does not exist against code '{code}'." ) . format ( code = coupons [ 0 ] . code ) ) return HttpResponse ( json . dumps ( { 'response' : 'success' , 'coupon_code_applied' : True } ) , content_type = 'application/json' )
this method utilize course coupon code .