예제 #1
0
def convert_weights(request, weight):

    region = _get_region(request)
    if region == 'US':
        # 100g = 3.5 ounces
        return weight_converter(weight)

    return weight
예제 #2
0
def convert_weights(request, weight):
    
    region = _get_region(request)
    if region == 'US':
        # 100g = 3.5 ounces
        return weight_converter(weight)
        
    return weight
예제 #3
0
def _payment_success(order):
    """
    Sends an email to a customer immediately after they successfully complete
    an order on the site. Also sends a confirmation email to the Admins
    """

    # PREPARE THE EMAIL INFORMATION
    recipient = order.owner.email
    activate(order.owner.language)
    subject_line = _("Order Confirmed - %(id)s - %(site)s") % {
        'id': order.invoice_id,
        'site': settings.SITE_NAME,
    }
    template = 'shop/emails/order_confirm_customer.txt'

    # PREPARE THE ORDER
    if order.address.country == 'US':
        weight_unit = 'oz'
    else:
        weight_unit = 'g'

    basket = _get_basket_value(order=order)
    print basket

    for item in basket['basket_items']:
        if item.item.weight:
            if order.address.country == 'US':
                item.weight = weight_converter(item.item.weight)
            else:
                item.weight = item.item.weight
        else:
            item.weight = None

    extra_context = {
        'order': order,
        'items': basket['basket_items'],
        'currency': basket['currency'],
        'total_price': basket['total_price'],
        'discount': basket['discount'],
        'postage_discount': basket['postage_discount'],
        'weight_unit': weight_unit,
    }

    _send_email(recipient, subject_line, template, extra_context)

    # ADMIN EMAIL (reset some of the values!!)
    recipient = settings.SITE_EMAIL
    lang = activate('en')
    template = 'shop/emails/order_confirm_admin.txt'
    _send_email(recipient, subject_line, template, extra_context, admin=True)

    return True
예제 #4
0
def _payment_success(order):
    """
    Sends an email to a customer immediately after they successfully complete
    an order on the site. Also sends a confirmation email to the Admins
    """

    # PREPARE THE EMAIL INFORMATION
    recipient = order.owner.email
    activate(order.owner.language)
    subject_line = _("Order Confirmed - %(id)s - %(site)s") % {"id": order.invoice_id, "site": settings.SITE_NAME}
    template = "shop/emails/order_confirm_customer.txt"

    # PREPARE THE ORDER
    if order.address.country == "US":
        weight_unit = "oz"
    else:
        weight_unit = "g"

    basket = _get_basket_value(order=order)
    print basket

    for item in basket["basket_items"]:
        if item.item.weight:
            if order.address.country == "US":
                item.weight = weight_converter(item.item.weight)
            else:
                item.weight = item.item.weight
        else:
            item.weight = None

    extra_context = {
        "order": order,
        "items": basket["basket_items"],
        "currency": basket["currency"],
        "total_price": basket["total_price"],
        "discount": basket["discount"],
        "postage_discount": basket["postage_discount"],
        "weight_unit": weight_unit,
    }

    _send_email(recipient, subject_line, template, extra_context)

    # ADMIN EMAIL (reset some of the values!!)
    recipient = settings.SITE_EMAIL
    lang = activate("en")
    template = "shop/emails/order_confirm_admin.txt"
    _send_email(recipient, subject_line, template, extra_context, admin=True)

    return True
예제 #5
0
def _payment_flagged(order):
    """
    Does the same as a normal payment email, but sends a 
    flagged order notification to the admin. The customer 
    doesn't see anything different, but admin gets a chance
    to check the order for irregularities.
    """
    # CUSTOMER GETS THEIR EMAIL AS NORMAL
    recipient = order.owner.email
    activate(order.owner.language)
    subject_line = _("Order Confirmed - %(id)s - %(site)s") % {
        'id': order.invoice_id,
        'site': settings.SITE_NAME
    }

    if order.address.country == 'US':
        weight_unit = 'oz'
    else:
        weight_unit = 'g'

    items = order.items.all()
    for item in items:
        if item.item.weight:
            if order.address.country == 'US':
                item.weight = weight_converter(item.item.weight)
            else:
                item.weight = item.item.weight
        else:
            item.weight = None

    template = 'shop/emails/order_confirm_customer.txt'
    extra_context = {
        'order': order,
        'items': items,
        'weight_unit': weight_unit,
    }

    _send_email(recipient, subject_line, template, extra_context)

    # ADMIN GETS WARNING ABOUT FLAGGED ORDER.
    recipient = settings.SITE_EMAIL
    template = 'shop/emails/order_confirm_admin.txt'
    extra_context = {'order': order}
    subject_line = "FLAGGED ORDER - %s" % order.invoice_id

    _send_email(recipient, subject_line, template, extra_context, admin=True)
    return
예제 #6
0
def _payment_flagged(order):
    """
    Does the same as a normal payment email, but sends a 
    flagged order notification to the admin. The customer 
    doesn't see anything different, but admin gets a chance
    to check the order for irregularities.
    """
    # CUSTOMER GETS THEIR EMAIL AS NORMAL
    recipient = order.owner.email
    activate(order.owner.language)
    subject_line = _("Order Confirmed - %(id)s - %(site)s") % {"id": order.invoice_id, "site": settings.SITE_NAME}

    if order.address.country == "US":
        weight_unit = "oz"
    else:
        weight_unit = "g"

    items = order.items.all()
    for item in items:
        if item.item.weight:
            if order.address.country == "US":
                item.weight = weight_converter(item.item.weight)
            else:
                item.weight = item.item.weight
        else:
            item.weight = None

    template = "shop/emails/order_confirm_customer.txt"
    extra_context = {"order": order, "items": items, "weight_unit": weight_unit}

    _send_email(recipient, subject_line, template, extra_context)

    # ADMIN GETS WARNING ABOUT FLAGGED ORDER.
    recipient = settings.SITE_EMAIL
    template = "shop/emails/order_confirm_admin.txt"
    extra_context = {"order": order}
    subject_line = "FLAGGED ORDER - %s" % order.invoice_id

    _send_email(recipient, subject_line, template, extra_context, admin=True)
    return