Index: branches/5.2.x/units/orders/orders_tag_processor.php =================================================================== diff -u -N -r14702 -r14723 --- branches/5.2.x/units/orders/orders_tag_processor.php (.../orders_tag_processor.php) (revision 14702) +++ branches/5.2.x/units/orders/orders_tag_processor.php (.../orders_tag_processor.php) (revision 14723) @@ -1,6 +1,6 @@ Application->recallObject('u', null, Array ('skip_autoload' => true)); - /* @var $user kDBItem */ + if ( isset($params['user_prefix']) ) { + $user =& $this->Application->recallObject($params['user_prefix']); + /* @var $user kDBItem */ + } + else { + $user =& $this->Application->recallObject('u', null, Array ('skip_autoload' => true)); + /* @var $user kDBItem */ + } $order =& $this->Application->recallObject($this->Prefix . '.last'); + /* @var $order OrdersItem */ $order_prefix = $params['type'] == 'billing' ? 'Billing' : 'Shipping'; + $names = explode(' ', $order->GetDBField($order_prefix . 'To'), 2); + + if ( !$user->GetDBField('FirstName') ) { + $user->SetDBField('FirstName', getArrayValue($names, 0)); + } + + if ( !$user->GetDBField('LastName') ) { + $user->SetDBField('LastName', getArrayValue($names, 1)); + } + $order_fields = Array ( - 'To', 'Company', 'Phone', 'Fax', 'Email', 'Address1', - 'Address2', 'City', 'State', 'Zip', 'Country' + 'Company', 'Phone', 'Fax', 'Email', 'Address1' => 'Street', + 'Address2' => 'Street2', 'City', 'State', 'Zip', 'Country' ); - $names = explode(' ', $order->GetDBField($order_prefix.'To'), 2); - if (!$user->GetDBField('FirstName')) $user->SetDBField('FirstName', getArrayValue($names, 0) ); - if (!$user->GetDBField('LastName')) $user->SetDBField('LastName', getArrayValue($names, 1) ); - if (!$user->GetDBField('Company')) $user->SetDBField('Company', $order->GetDBField($order_prefix.'Company') ); - if (!$user->GetDBField('Phone')) $user->SetDBField('Phone', $order->GetDBField($order_prefix.'Phone') ); - if (!$user->GetDBField('Fax')) $user->SetDBField('Fax', $order->GetDBField($order_prefix.'Fax') ); - if (!$user->GetDBField('Email')) $user->SetDBField('Email', $order->GetDBField($order_prefix.'Email') ); - if (!$user->GetDBField('Street')) $user->SetDBField('Street', $order->GetDBField($order_prefix.'Address1') ); - if (!$user->GetDBField('Street2')) $user->SetDBField('Street2', $order->GetDBField($order_prefix.'Address2') ); - if (!$user->GetDBField('City')) $user->SetDBField('City', $order->GetDBField($order_prefix.'City') ); - if (!$user->GetDBField('State')) $user->SetDBField('State', $order->GetDBField($order_prefix.'State') ); - if (!$user->GetDBField('Zip')) $user->SetDBField('Zip', $order->GetDBField($order_prefix.'Zip') ); - if (!$user->GetDBField('Country')) $user->SetDBField('Country', $order->GetDBField($order_prefix.'Country') ); + foreach ($order_fields as $src_field => $dst_field) { + if ( is_numeric($src_field) ) { + $src_field = $dst_field; + } + if ( !$user->GetDBField($dst_field) ) { + $user->SetDBField($dst_field, $order->GetDBField($order_prefix . $src_field)); + } + } + $cs_helper =& $this->Application->recallObject('CountryStatesHelper'); /* @var $cs_helper kCountryStatesHelper */