I don't think context will contain a 'course_id' key if order_items.count() != 1

I'm assuming that the context.update on line 125 is where this is being set, but that only is called when there is a single item in the order.