function commerce_activate_field in Commerce Core 7
Attempts to directly activate a field that was disabled due to its module being disabled.
The normal API function for updating fields, field_update_field(), will not work on disabled fields. As a workaround, this function directly updates the database, but it is up to the caller to clear the cache.
Parameters
$field_name: The name of the field to activate.
Return value
Boolean indicating whether or not the field was activated.
9 calls to commerce_activate_field()
- commerce_customer_configure_customer_fields in modules/
customer/ commerce_customer.module - Configures fields referencing customer profile types defined by enabled modules and configures the fields on those profile types if necessary.
- commerce_customer_configure_customer_profile_type in modules/
customer/ commerce_customer.module - Ensures the address field is present on the specified customer profile bundle.
- commerce_delete_field in ./
commerce.module - Enables and deletes the specified field.
- commerce_delete_instance in ./
commerce.module - Deletes the specified instance and handles field cleanup manually in case the instance is of a disabled field.
- commerce_order_configure_customer_profile_type in modules/
order/ commerce_order.module - Configure the customer profile reference fields for the specified order type.
File
- ./
commerce.module, line 169 - Defines features and functions common to the Commerce modules.
Code
function commerce_activate_field($field_name) {
// Set it to active via a query because field_update_field() does
// not work on inactive fields.
$updated = db_update('field_config')
->fields(array(
'active' => 1,
))
->condition('field_name', $field_name, '=')
->condition('deleted', 0, '=')
->execute();
return !empty($updated) ? TRUE : FALSE;
}