1. Hynek Cernoch
  2. satchmo-test

Commits

Chris Moffitt  committed 191ac4d

Handle different ship to and bill to addressees more gracefully.

  • Participants
  • Parent commits 1ddcd34
  • Branches default

Comments (0)

Files changed (5)

File satchmo/apps/satchmo_store/contact/forms.py

View file
         copy_address = data['copy_address']
 
         ship_address = customer.shipping_address
-
-        if copy_address:
+        try:
+            setattr(ship_address, "addressee",data.get('ship_addressee', ""))
+            setattr(bill_address, "addressee",data.get('addressee', ""))
+        except AttributeError:
+            pass
+        # If we are copying the address and one isn't in place for shipping
+        # copy it
+        if not getattr(ship_address, "addressee", False) and copy_address:
+            try:
+                ship_address.addressee = bill_address.addressee
+            except AttributeError:
+                pass
+                
+        # Make sure not to overwrite a custom ship to name
+        if copy_address and getattr(ship_address, "addressee", "") == getattr(bill_address, "addressee", ""):
             # make sure we don't have any other default shipping address
             if ship_address and ship_address.id != bill_address.id:
                 ship_address.delete()
             bill_address.is_default_shipping = True
 
         bill_address.save()
-
-        if not copy_address:
+        # If we have different ship to and bill to names, preserve them
+        if not copy_address or getattr(ship_address, "addressee", "") != getattr(bill_address, "addressee", ""):
             if not ship_address or ship_address.id == bill_address.id:
                 ship_address = AddressBook()
 

File satchmo/apps/satchmo_store/contact/templates/contact/_contact_info_form_js.html

View file
     var full_name = $.trim(first_name + ' ' + last_name);
     var old_full_name = $.trim(old_first_name + ' ' + old_last_name);
     if ($('#id_addressee').attr('value') === old_full_name) {
-	$('#id_addressee').attr('value', full_name);
+    $('#id_addressee').attr('value', full_name);
     }
     if ($('#id_ship_addressee').attr('value') === old_full_name) {
-	$('#id_ship_addressee').attr('value', full_name);
+    $('#id_ship_addressee').attr('value', full_name);
     }
     $('#id_first_name').data('old_first_name', first_name);
     $('#id_last_name').data('old_last_name', last_name);

File satchmo/apps/satchmo_store/contact/templates/contact/_contact_info_form_shipping.html

View file
 
     {% if country %}
       {% if form.fields.ship_state.choices %}
-       <tr>
+       <tr class="shiprow">
          <td><label for="id_ship_state">{% if country.get_admin_area_display %}{{ country.get_admin_area_display }}{% else %}{% trans "State/Province" %}{% endif %} {% if form.ship_state.field.required %}*{% endif %}</label></td>
          <td><p id="id_ship_state_loading" style="display: none">Loading...</p> {{ form.ship_state }}</td>
        </tr>

File satchmo/apps/satchmo_store/shop/templates/shop/_order_details.html

View file
 {{ order.contact.primary_phone.phone }}<br/>
 
 <h4>{% trans "Billing Information" %}</h4>
+{{ order.bill_addressee }}<br/>
 {{ order.full_bill_street|linebreaksbr }}<br/>
 {{ order.bill_city }}<br/>
 {{ order.bill_state }}<br/>
 
 {% if order.is_shippable %}
 <h4>{% trans "Shipping Address" %}</h4>
+{{ order.ship_addressee }}<br/>
 {{ order.full_ship_street|linebreaksbr }}<br/>
 {{ order.ship_city }}<br/>
 {{ order.ship_state }}<br/>

File satchmo/apps/satchmo_store/shop/templates/shop/_order_tracking_details.html

View file
 
 {% if order.is_shippable %}
 <h4>{% trans "Shipping To" %}</h4>
+{{ order.ship_addressee }}<br/>
 {{ order.full_ship_street }}<br/>
 {{ order.ship_city }}<br/>
 {{ order.ship_state }}<br/>