'Add a CertificateItem to an order
Returns the CertificateItem object after saving
`order` - an order that this item should be added to, generally the cart order
`course_id` - the course that we would like to purchase as a CertificateItem
`cost` - the amount the user will be paying for this CertificateItem
`mode` - the course mode that this certificate is going to be issued for
This item also creates a new enrollment if none exists for this user and this course.
Example Usage:
cart = Order.get_cart_for_user(user)
CertificateItem.add_to_order(cart, \'edX/Test101/2013_Fall\', 30, \'verified\')'

@classmethod
@transaction.atomic
def add_to_order(cls, order, course_id, cost, mode, currency='usd'):

    super(CertificateItem, cls).add_to_order(order, course_id, cost, currency=currency)
    course_enrollment = CourseEnrollment.get_or_create_enrollment(order.user, course_id)
    valid_modes = CourseMode.modes_for_course_dict(course_id)
    if (mode in valid_modes):
        mode_info = valid_modes[mode]
    else:
        msg = u'Mode    {mode}    does    not    exist    for    {course_id}'.format(mode=mode, course_id=course_id)
        log.error(msg)
        raise InvalidCartItem(_(u'Mode    {mode}    does    not    exist    for    {course_id}').format(mode=mode, course_id=course_id))
    (item, _created) = cls.objects.get_or_create(order=order, user=order.user, course_id=course_id, course_enrollment=course_enrollment, mode=mode)
    item.status = order.status
    item.qty = 1
    item.unit_cost = cost
    item.list_price = cost
    course_name = modulestore().get_course(course_id).display_name
    item.line_desc = _('{mode_name}    for    course    {course}').format(mode_name=mode_info.name, course=course_name)
    item.currency = currency
    order.currency = currency
    order.save()
    item.save()
    course_enrollment.send_signal(EnrollStatusChange.paid_start, cost=cost, currency=currency)
    return item
