Ubercart Profile (uc_profile) module extended

Extensions to the ubercart profile module which allow you to add drupal profile fields on checkout

I was approached by a client to extend certain functionality in the uc_profile module.

The Clients

SuitsAndThais.com sells custom made tailored suits. They require their readers to be able to input their measurements along with their order. They were using Drupal Profile module to allow for this information to be inputted upon registration and UC Profile module to inject this information into the Ubercart Checkout.

The Workflow

  1. User browses the site and finds a suit they want.
  2. They add this item to their cart and checkout.
  3. A user must be registered to checkout, they are requested to create an account.
  4. The "profile" module injects fields into this users registration process (General Measurements, Lower Body Measurements, Upper Body Measurements).
  5. Upon registration, the customer is redirected back to checkout.
  6. The uc_profile module, injects the additional profile categories input fields into the checkout process to be edited by user if required.
  7. Upon successful order, these profile fields are now associated with the order and sent out on the customers invoice and displayed with the order.

The problem

Previously uc_profile only worked with a single profile category named "Ubercart". Also none of the additional checkout information was made available to the orders invoice or admin interface.

Solution

I extended the module to take any arbitrary profile category and inject it into the checkout process.

Minor additions to the administration interface to allow for the configuration of profile categories to be added into the checkout process. The administrator can also choose if they would like these expanded or collapsed by default.

The details of these additional checkout fields are made available into the invoice and order areas for quick reference with the sale.

Download

You can download my UC Profile extension here:

http://digibits.org/sites/default/files/files/uc_profile-20100712.tgz

Comments

Incompatible with add-on modules

2 initial issues that I ran into when implementing this updated version: 1. It is incompatible with other profile modules such as profile_permissions and profile_checkboxes 2. When set to be collapsed by default, the contents is not populated. Thoughts?

Support for other profile modules

I have not tested this module with other profile modules, including profile permissions or profile checkboxes. There probably needs to be some additional checks and controls for the code to work with these modules. Can you confirm that the old uc_profile module worked with these additional modules? Much of my code is the same as the old uc_profile module. As for no content on collapsed by default, that's probably a bug. I'll look into it when I get a chance.

I would assume that it didn't

I would assume that it didn't support these other modules -- I am not a coder so the best I could do was to add two chunks to the uc_profile that replicated the changes the two other modules we're making. I wrapped each hunk of code in a 'module_exists'. I don't think that this is the appropriate method for solving this issue, but I needed it fixed asap for a client demonstration.

It sounds like you're on the right track

I would be looking into the other modules to see what they're doing as well. I assume'd I would be wrapping additional code around "module_exists()" type declarations as well. Unfortunately I will not have the time this week to look into the problem, as I myself am busy with client demonstrations. I will look into these issues when I have time, but not before then. Sorry :(

Data flow

Does your extension update the profile data from the uc checkout?

Yes.

Yes. The data which is entered/changed on checkout is saved after a successful purchase goes through. If you don't want this, there's a single 1-2 line hook that you could comment out.

Data Flow (con't)

That's great. When you say that the profile is updated once the purchase goes through do you mean once the UC workflow goes to "Complete"? If so, can it be changed to update the Drupal profile as soon as the customer is done with the Checkout process (no payment yet, we use checks only but want to give a trial access while the check is in route). Thanks for your feedback and clarification.

I mean once the sale goes

I mean once the sale goes through I believe. You'll need to see in the code exactly what hook is being used...but it believe it's after the "successful purchase". I don't think it has to do with UC WorkFlow, but it might.