Quote:My only critique is

Posts: 300
Joined: 08/28/2007
Early adopter... addicted to alphas.Not KulvikTheminator

Quote:
My only critique is that you have added code from other parts of the module to the uc_addresses_user function. I'm not a programmer by trade, but I think the concept of Object Oriented Programming is to not reuse code, but to reference/use one function over and over to do what you need.

I understand this and I am striving for it but I'm not a native programmer either, just learning this stuff as I go along. At the moment, with my very basic skills I'm finding that I need different things returned, this could be due to the functions not being reusable enough or my lack of knowledge of how to manipulate things before they go into or after they come out of functions.

Quote:
I think you can get your form for registration by using the uc_addresses_pane_address() function in the uc_addresses_address_pane.inc file. If you added another "case" to that function for 'register' (or just use the 'new' case)...

Yes, this would seem like the best idea. I can add a new case to the switch in uc_addresses_pane_address() but using the 'new' case would be better. My only problem with using the 'new' case was that it returns some weird array which I'm not sure how to feed that into the $form. Should I be manipulating the returned value after it comes out of the function? As you can see I'm still stuck on how to theme the form properly. Insight on this would be appreciated.

Quote:
...and added a hook_menu() to the uc_addresses_menu() function for the path that a user registers at, I think it would work.

I guess this would be to fire off callback when a path is visited. Not quite sure what function but what I have done actually works pretty well, albeit with some pretty major bumps. I'm open to ideas so if you'd like to elaborate on this I would be more than happy to refactor things.

Quote:
You can also perform the insert into the database with the uc_addresses_add_address function near the bottom of uc_addresses.module.

It just makes it easier to maintain in the future.

The uc_addresses_add_address() function seems to take an object and not an array like $edit. If I knew how to convert an array into an object (which seems to be what uc_addresses_add_address() needs) then I would have used that. I just wanted to get this working so I could fine tune it later. Is there a standard way in PHP to convert an array into an object? Would it be better for the uc_addresses_add_address() function to accept both arrays and objects, or just arrays? Your input here would be good.

Quote:
I'm not sure how to override the forms at check out without editing the Core Ubercart code. That was my next step for development on this module. I know it can be done without making changes. There is a hook that should work, I just haven't had time yet to figure it out. I believe it is the hook_form_alter() function..

You are right, it is hook_form_alter(). I have been working on this and have the following:

<?php
function uc_addresses_form_alter($form_id, &$form) {
  global
$user;
  if (
$form_id == 'uc_cart_checkout_form') {
   
$addresses[] = array('Select one...');
   
$addresses[] = uc_get_addresses($user->uid, $type);
    if (
$profile_addresses = uc_addresses_get_address($user->uid, NULL, 0)) {
      foreach (
$profile_addresses as $index => $profile_address) {
       
$addresses[] = $profile_address;
      }
    }
   
dprint_r($addresses);
   
//dprint_r($form['panes']['delivery']['delivery_address_select']['#options']);
    //$form['panes']['delivery']['delivery_address_select']['#options'] = $addresses;
 
}
}
?>

The function uc_get_addresses() returns an array which is exactly what is needed but uc_addresses_get_address() returns an object. This is the same problem as above, I guess I need to loop over the elements in the object and output an array?

Sorry for my newbie questions, I'm working on it though!

Storing Address information in User Profile By: bendiy (74 replies) Thu, 10/25/2007 - 19:04