Skip to content

Commit

Permalink
Try to get the email address from guest customers (=not logged in use…
Browse files Browse the repository at this point in the history
…rs).
  • Loading branch information
philippeowagner committed Oct 31, 2013
1 parent 9aeca39 commit ff4c9d9
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions shop_simplenotifications/models.py
Expand Up @@ -5,7 +5,7 @@
from django.template import loader, RequestContext

from shop.order_signals import confirmed

from shop.utils.address import get_shipping_address_from_request, get_billing_address_from_request

def subject(template_name):
"""Returns the email subject based on the subject template."""
Expand Down Expand Up @@ -51,7 +51,15 @@ def payment_instructions_email_notification(sender, **kwargs):
'shop_simplenotifications/payment_instructions_body.txt'
request = kwargs.get('request')
order = kwargs.get('order')
if order.user and order.user.email:
emails = []
if order.user and order.user.email:
emails.append(order.user.email)
if get_shipping_address_from_request(request):
emails.append(get_shipping_address_from_request(request))
if get_billing_address_from_request(request):
emails.append(get_billing_address_from_request(request))

if emails:
subject = loader.render_to_string(
subject_template_name,
RequestContext(request, {'order': order})
Expand All @@ -63,8 +71,7 @@ def payment_instructions_email_notification(sender, **kwargs):
)
from_email = getattr(settings, 'SN_FROM_EMAIL',
settings.DEFAULT_FROM_EMAIL)
send_mail(subject, body, from_email,
[order.user.email,], fail_silently=False)
send_mail(subject, body, from_email, emails, fail_silently=False)

confirmed.connect(payment_instructions_email_notification)

0 comments on commit ff4c9d9

Please sign in to comment.