Hi I am seeking something like this where there is one fixed billing profile which can be updated via a tab in the user profile. It's for a subscription product although I haven't even begun to look at the subscription contrib module for commerce.

One thing I just discovered is that I'm unable to uninstall this module as it's stating dependency on fields, specifically on modules list:
Required by: Drupal (Field type(s) in use - see Field list)
Can you reassure me on the best way to disable the module? i.e.. delete the addressbook_saved_profiles field from the billing profile? Will there be any residue on the database or in fields that I should be aware of after disabling?

I realize this is in the beginning stages so I'm requesting support to do a clean uninstall.

Thanks

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

blasthaus’s picture

Title: how to uninstall the module » how to cleanly uninstall the Commerce Addressbook module
blasthaus’s picture

Following up here based on a better understanding of how fields work.
A helpful post here describing the same issue (but with different modules) can be found here http://drupal.org/node/1284332
More specifically this is the recommended approach Field types should be defined by one module and implemented by a separate module.

Notes on how to disable the module:

  1. back up your db
  2. remove the addressbook field from the field_config table
  3. remove the addressbook field instance from the field_config_instance table
  4. disable the module.
  5. remove the field_data_addressbook_saved_profiles table (optional as this destroys data created by the module)
  6. remove the field_revision_addressbook_saved_profiles table (optional as this destroys data created by the module)
  7. remove the commerce_addressbook_auto_prefill row from the variable table (optional as this destroys data created by the module)

Suggestion: implement a simple uninstall function which integrates into the development of the module(s).

/**
 * Implements hook_uninstall().
 *
 */
function commerce_addressbook_uninstall() {
  // Delete vars
    variable_del('commerce_addressbook_auto_prefill');

  // TODO: Delete fields. this is just a placeholder and will not function at present
/*  foreach (array_keys(_commerce_addressbook_installed_fields()) as $field) {
    field_delete_field($field);
  }
*/

  // TODO: Delete field instances. this is just a placeholder and will not function at present
/*  $instances = field_info_instances('commerce_addressbook_saved_profiles', 'addressbook_saved_profiles');
  foreach ($instances as $instance_name => $instance) {
    field_delete_instance($instance);
  }
*/

  // Purge all remaining field info.
  field_purge_batch(1000);

}
svendecabooter’s picture

Status: Active » Needs work
bojanz’s picture

Title: how to cleanly uninstall the Commerce Addressbook module » Provide missing uninstall code
Category: support » task
Status: Needs work » Needs review
FileSize
1.59 KB

The Addressbook 7.x-1.x branch created an interesting problem because it defines a field type AND creates instances of that type in the same module,
which is forbidden in newer Drupal releases (but probably wasn't at the time the code was written).

Here's a patch that should enable uninstall. It's completely untested.
Can someone with a 7.x-1.x install test?

bojanz’s picture

FileSize
1.59 KB

Use this one instead, the commerce_delete_fields() parameter was wrong.

kiwimind’s picture

@bojanz, thanks for the info. Just trying to finish off the issue I posted #1418518: Remove address dropdown when editing a customer's order.

I've got a couple of issues though...

1) I presume that the disable function name needs to be "function commerce_addressbook_disable", not "function commerce_addressbook_enable".

2) Even with this rename, I am unable to disable the module due to dependencies, which stops me from uninstalling it (as far as I'm aware).

bojanz’s picture

Yeah, it needs to be commerce_addressbook_disable() or commerce_addressbook_uninstall().
The code is untested (didn't have time to follow it though), so it might need additional tweaks. I'll look into it after DrupalCon if nobody does it before then.

kiwimind’s picture

Ok, cool. Thanks.

Have a great time in Denver.

bojanz’s picture

FileSize
1.59 KB

Rerolled to fix:

1) I presume that the disable function name needs to be "function commerce_addressbook_disable", not "function commerce_addressbook_enable".

Don't have time to push this further right now. The patch should either work or be very very close.

bojanz’s picture

Status: Needs review » Closed (won't fix)

Nevermind, we have an upgrade path to 2.x now.

kiwimind’s picture

Awesome, thanks, will look at testing the upgrade instead of persuing this.