Example1: After altering a profile at checkout you progress to the overview page. When deciding to go back using the "Go back" form button, the altered values are being overwritten by Commerce Extra Address Populate.

Example2: When leaving the checkout progress after altering a profile and then returning to the checkout pages, the altered values are being overwritten by Commerce Extra Address Populate.

This can be overcome by checking whether the field has a value or not by changing lines 79-81 at commerce_extra_address_populate.module from:

if (isset($form['commerce_customer_address'][$langcode][0]['#address'][$key])) {
  $form['commerce_customer_address'][$langcode][0]['#address'][$key] = $value;
}

to:

if (isset($form['commerce_customer_address'][$langcode][0]['#address'][$key]) && empty($form['commerce_customer_address'][$langcode][0]['#address'][$key])) {
  $form['commerce_customer_address'][$langcode][0]['#address'][$key] = $value;
}

Thanks a lot for the effort!

Comments

5n00py’s picture

Assigned: Unassigned » 5n00py
Category: bug » task

Thank you for your report, it need to be fixed!
I will do this soon.

5n00py’s picture

Status: Active » Fixed

I think would be better to populate data only one time.
Simple use case is:

  1. Go to checkout, module copy data from profile
  2. I want to delete some data from order, then go next. Or I change address 1 field, and I don't need secon address line.
  3. Press continue
  4. Go back. Fail, my empty fields filled again...

Diff

 function commerce_extra_address_populate_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) {
-
+  if (!isset($entity->is_new)) {
+    return;
+  }
   // Ensure, we're attaching field into right entity type
   if ($entity_type == 'commerce_customer_profile') {

Committed to 7.x-1.x

lmeurs’s picture

Yes, that makes more sense, otherwise empty fields would always be repopulated, also when they were left blank on purpose.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.