diff --git a/shipping/uc_quote/src/Plugin/Ubercart/CheckoutPane/QuotePane.php b/shipping/uc_quote/src/Plugin/Ubercart/CheckoutPane/QuotePane.php index ea45730..0c5708b 100644 --- a/shipping/uc_quote/src/Plugin/Ubercart/CheckoutPane/QuotePane.php +++ b/shipping/uc_quote/src/Plugin/Ubercart/CheckoutPane/QuotePane.php @@ -58,6 +58,11 @@ class QuotePane extends CheckoutPanePluginBase { '#weight' => 1, ); + // If this was an Ajax request, we reinvoke the 'prepare' op to ensure + // that we catch any changes in panes heavier than this one. + if ($form_state->getTriggeringElement()) { + $this->prepare($order, $form, $form_state); + } $contents['quotes'] += $order->quote_form; $form_state->set(['uc_ajax', 'uc_quote', 'panes][quotes][quote_button'], array( diff --git a/uc_cart/src/Plugin/Ubercart/CheckoutPane/AddressPaneBase.php b/uc_cart/src/Plugin/Ubercart/CheckoutPane/AddressPaneBase.php index 4d04339..7fb09c9 100644 --- a/uc_cart/src/Plugin/Ubercart/CheckoutPane/AddressPaneBase.php +++ b/uc_cart/src/Plugin/Ubercart/CheckoutPane/AddressPaneBase.php @@ -101,6 +101,8 @@ abstract class AddressPaneBase extends CheckoutPanePluginBase { $contents['address']['#hidden'] = $this->configuration['default_same_address']; } + // If this was an Ajax request, update form input values for the + // copy and select address features. if ($element = $form_state->getTriggeringElement()) { $input = $form_state->getUserInput(); @@ -110,7 +112,6 @@ abstract class AddressPaneBase extends CheckoutPanePluginBase { if (substr($field, 0, strlen($source)) == $source) { $field = str_replace($source, $pane, $field); $input['panes'][$pane][$field] = $value; - $order->$field = $value; } } } @@ -119,7 +120,6 @@ abstract class AddressPaneBase extends CheckoutPanePluginBase { $address = $addresses[$element['#value']]; foreach ($address as $field => $value) { $input['panes'][$pane][$field] = $value; - $order->{$pane . '_' . $field} = $value; } $contents['address']['#default_value'] = $order->getAddress($pane); } @@ -149,6 +149,12 @@ abstract class AddressPaneBase extends CheckoutPanePluginBase { } } } + if (isset($panes[$pane]['select_address']) && $panes[$pane]['select_address'] >= 0) { + $addresses = uc_select_addresses(\Drupal::currentUser()->id(), $pane); + foreach ($addresses[$panes[$pane]['select_address']] as $field => $value) { + $address->$field = $value; + } + } $order->setAddress($pane, $address); return TRUE; }