You are here

function commerce_addressbook_profile_is_incomplete in Commerce Addressbook 7.3

Returns whether the provided customer profile is incomplete.

Incomplete profiles need to be presented to the customer and completed before checkout is completed.

A profile is incomplete if:

  • $profile->data['incomplete'] = TRUE, meaning that it was created with the

intention of being edited during the customer's first checkout.

  • validation via the Entity Wrapper fails, because a required field is

empty or a validation callback specified by the field type returned FALSE.

Parameters

$profile: The customer profile entity.

Return value

TRUE if the customer profile is incomplete and should be presented to the customer for editing. Otherwise, FALSE.

1 call to commerce_addressbook_profile_is_incomplete()
commerce_addressbook_pane_checkout_form in ./commerce_addressbook.checkout_pane.inc
Checkout pane callback: returns a customer profile edit form.

File

./commerce_addressbook.module, line 245
Defines addressbook functionality for customer profiles, allowing them to be reused and managed on a per-user basis.

Code

function commerce_addressbook_profile_is_incomplete($profile) {
  if (!empty($profile->data['incomplete'])) {
    return TRUE;
  }
  $wrapper = entity_metadata_wrapper('commerce_customer_profile', $profile);
  foreach (field_info_instances('commerce_customer_profile', $profile->type) as $instance) {
    $value = $wrapper->{$instance['field_name']}
      ->value();
    if (!$wrapper->{$instance['field_name']}
      ->validate($value)) {
      return TRUE;
    }
  }
  return FALSE;
}