function commerce_admin_order_advanced_profile_copy in Commerce Admin Order Advanced 7
Provides a method to copy customer profiles.
Helper function to copy a customer profile from one type to another through the admin order form.
1 call to commerce_admin_order_advanced_profile_copy()
- commerce_admin_order_advanced_profile_copy_validate in ./
commerce_admin_order_advanced.module - Validation callback for the admin copy address profile ajax function.
File
- ./
commerce_admin_order_advanced.module, line 398 - Provides advanced admin order interface.
Code
function commerce_admin_order_advanced_profile_copy($info, &$target, $source, &$form_state) {
list($entity_type, $bundle, $language) = $info;
// Loop over all the field instances that could be attached to this entity.
foreach (field_info_instances($entity_type, $bundle) as $field_name => $instance) {
$field = NULL;
$field = $source[$language]['profiles'][0][$field_name];
// Loop over the source field value and copy its items to the target.
if (is_array($field)) {
foreach ($field as $langcode => $items) {
if (is_array($items)) {
foreach ($items as $delta => $item) {
$target[$language]['profiles'][0][$field_name][$langcode][$delta] = $item;
}
}
}
}
}
}