Accounts created in drupal do not include addresses, normally. This leads to at least two errors.

1. Checkout gets me to a page not found error.
2. Attempting to use a customer list gives the warning set out below

Error 1 goes away when I go and add an address to the customer's address book, but there is no prompt to do so.

Here is a discussion of the error message: http://www.zen-cart.com/forum/showthread.php?t=84776

Does this occur in normal 1.3.7 installations?

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/.sami/moradzadeh/testing.com/zencart/admin/customers.php on line 1099

Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /home/.sami/moradzadeh/testing.com/zencart/admin/customers.php on line 1101

Warning: reset() [function.reset]: Passed variable is not an array or object in /home/.sami/moradzadeh/testing.com/zencart/admin/includes/classes/object_info.php on line 29

Warning: Variable passed to each() is not an array or object in /home/.sami/moradzadeh/testing.com/zencart/admin/includes/classes/object_info.php on line 30

CommentFileSizeAuthor
#9 drupalzen_observer.patch689 bytescayenne

Comments

cayenne’s picture

Just noting that the issue goes away when I deinstall the drupal/zc link, so we are homing in on it!

ronan’s picture

Thanks for investigating all this. If you're comfortable with debugging php and can provide patches for the issues you find, I'd love to have your help polishing the module. If you're not comfortable getting your hands dirty, then I would say this module is not ready for you yet.

Finding issues is a great help though.

Thanks
Ronan

cayenne’s picture

Oh I have nice dirty hands, though more with Java than PHP. I am narrating my progress in the hope that you or someone may chime in with "oh that is normal" or "oh, here is a hint."

Anyway, here is what I have learned

a. The problem goes away when you turn OFF "single sign-on" so that is an adequate, if sad, workaround and
b. The problem sort of goes away when you comment out the following code. By "sort of", I mean that it no longer checks for a billing address. THe good news is that the issue is restricted to a range of about a dozen lines. I am more familiar with drupal hacking than zc, but I think we are close.....

 case 'NOTIFY_HEADER_START_CHECKOUT_SHIPPING':
        if( defined( 'DRUPAL_SINGLE_SIGNON' ) && DRUPAL_SINGLE_SIGNON && !$_SESSION['customer_default_address_id'] && !$_SESSION['sendto'] ) {
          zen_redirect( zen_href_link( 'checkout_shipping_address' ) );
        } else if ( $_SESSION['sendto'] ) { 
          $this->setPrimaryAddress( $_SESSION['sendto'] );
        }
      break;
      case 'NOTIFY_HEADER_START_CHECKOUT_PAYMENT':
        if( defined( 'DRUPAL_SINGLE_SIGNON' ) && DRUPAL_SINGLE_SIGNON && !$_SESSION['customer_default_address_id'] && !$_SESSION['billto'] && !$_SESSION['sendto'] ) {
          zen_redirect( zen_href_link( 'checkout_billing_address' ) ); 
        } else if ( $_SESSION['billto'] ) {
          $this->setPrimaryAddress( $_SESSION['billto'] );
        }
      break;
ronan’s picture

Yeah, looks like you've run into the same wall I ran into before the project timeline forced me to draw my attention elsewhere, and jettison user integration for that project altogether (it was not a priority for the client).

The basic problem I'm trying to solve here is that if you sign up with Drupal and then try to check out with zen cart, the system will not have a physical address for you. Zen cart requires an address for checkout, and it assumes that one is present since signing up for a zen cart account requires you to enter an address. The hack you're seeing above is my attempt to force a user to enter an address the first time he checks out, but clearly it's not a very elegant (or indeed functional) solution.

I'm very much open to other ideas for solutions here.

The converse issue which you may have discovered is that if you go backwards (ie: an existing zen cart user logs into Drupal) there is no username on file for that user (zen cart does not have usernames) so I'm using the user's email address as a username, which means it's displayed on any post they create making it a spam-bot haven. This will only be a problem for people with pre-existing zen installations who wish to add a Drupal install and allow their zen customers to login to Drupal. If you start with two fresh installs, this module redirects all users through Drupal for ease of management.

cayenne’s picture

Okay, here are a coupla thoughts, and a request

The request is can you tell me what zencart module the code you provide is overriding.

The thoughts are

a. Either restrict the signups to drupal only or add a line that obscures or deletes the domain name when supplying a username to drupal. Maybe just delete the "@" and the content after the "." In any case, the default condition works.

b. If the code looks to see whether there is a billing address, whether or not there is a single-sign-on, and prompts for one, that'd be better, I think. Can you steer me to the correct module in ZenCart that manages that part of checkout? I'll find it on my own, but you can short-circuit my efforts!

ronan’s picture

a. Either restrict the signups to drupal only or add a line that obscures or deletes the domain name when supplying a username to drupal. Maybe just delete the "@" and the content after the "." In any case, the default condition works.

I believe this is restrictable by the admin I believe, and I wanted to implement that direction as I have a handful of clients with zencart installs who may want to move to a drupal/zen environment at some point. I think what I'm doing is replacing the @ with a dash or similar, I'd thought of removing the domain, but I'd have to do extra checks for uniqueness, and I figured I'd solve that problem when I needed to.

b. If the code looks to see whether there is a billing address, whether or not there is a single-sign-on, and prompts for one, that'd be better, I think. Can you steer me to the correct module in ZenCart that manages that part of checkout? I'll find it on my own, but you can short-circuit my efforts!

I'm not sure what you're describing here. You mean prompt for billing address on checkout? That is what the code is supposed to do now. The code in zencart for collecting address is usually the signup page (includes/modules/pages/create_account/header_php.php). You should also check out the various steps of checkout at includes/modules/pages/checkout_*.

Good luck wading through the zen cart code figuring out the flow of control. You're in for a mind bending adventure. :)

cayenne’s picture

Assigned: Unassigned » cayenne
Status: Active » Needs review

YAHOO!

Okay, found it, at least for 1.3.8.

Change
In drupalzen_observer.php at line 126, change

zen_redirect( zen_href_link( 'checkout_billing_address' ) );
to
zen_redirect( zen_href_link( 'checkout_payment_address' ) );

Looks like the file name changed at some point. Looking at my 1.3.7 site, it appears that this may be needed there too.
Thoughts?

Check it out at http://www.yachtpc.dreamhosters.com/

ronan’s picture

Hmmm... a quick check of my 1.3.7 codebase shows that 'checkout_payment_address' is indeed the page. Not sure how that ever worked.

Good find, you mind posting it as a patch?

Thanks
Ronanx

cayenne’s picture

StatusFileSize
new689 bytes

Here is the patch, which I had to learn how to generate.

To summarize, this corrects the drupalzen_observer.php file which calls an incorrect page when checking out.

ronan’s picture

Thanks for the patch. It didn't actually apply, but i'm no expert on patches so I really can't tell you why. I applied by hand and have committed the code up to HEAD.

Thanks again, and let me know what else you run into along the way.

cayenne’s picture

Ah. It was my first patch. But as it was only one word, I am glad that doing it by hand helped.

babbage’s picture

Status: Needs review » Fixed

(Just cleaning up some status items in this issue queue as I read through it.)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.