'updating order type. This method wil inspect the quantity associated with the OrderItem.
In the application, it is implied that when qty > 1, then the user is to purchase
\'RegistrationCodes\' which are randomly generated strings that users can distribute to
others in order for them to enroll in paywalled courses.
The UI/UX may change in the future to make the switching between PaidCourseRegistration
and CourseRegCodeItems a more explicit UI gesture from the purchaser'

def update_order_type(self):

    cart_items = self.orderitem_set.all()
    is_order_type_business = False
    for cart_item in cart_items:
        if (cart_item.qty > 1):
            is_order_type_business = True
    items_to_delete = []
    old_to_new_id_map = []
    if is_order_type_business:
        for cart_item in cart_items:
            if hasattr(cart_item, 'paidcourseregistration'):
                course_reg_code_item = CourseRegCodeItem.add_to_order(self, cart_item.paidcourseregistration.course_id, cart_item.qty)
                course_reg_code_item.list_price = cart_item.list_price
                course_reg_code_item.unit_cost = cart_item.unit_cost
                course_reg_code_item.save()
                items_to_delete.append(cart_item)
                old_to_new_id_map.append({'oldId': cart_item.id, 'newId': course_reg_code_item.id})
    else:
        for cart_item in cart_items:
            if hasattr(cart_item, 'courseregcodeitem'):
                paid_course_registration = PaidCourseRegistration.add_to_order(self, cart_item.courseregcodeitem.course_id)
                paid_course_registration.list_price = cart_item.list_price
                paid_course_registration.unit_cost = cart_item.unit_cost
                paid_course_registration.save()
                items_to_delete.append(cart_item)
                old_to_new_id_map.append({'oldId': cart_item.id, 'newId': paid_course_registration.id})
    for item in items_to_delete:
        item.delete()
    self.order_type = (OrderTypes.BUSINESS if is_order_type_business else OrderTypes.PERSONAL)
    self.save()
    return old_to_new_id_map
