This really doesn't work, here is a small patch to fix some typos, but there are some more critical errors in the logic that this patch doesn't fix.

After this patch address submission forms show but validation fails because that only checks that a user has choosen a adress but the anonymous user can't choose adress and the submitted fields are never checked. This means there is no way to buy for anonymous users.

If we skip validation we get another submission form asking as to review our adresses but the previous values are not remembered.

Comments

ñull’s picture

Is your patch related to this issue? If it is, can I mark it fixed?

ñull’s picture

Sorry, I forgot to include the link: http://drupal.org/node/34902

pz’s picture

The main problem is the same -- anonymous purchases doesn't work, but this issue is agains 4.6 the other against cvs. The patch only fixes some typos not the main problem.

jeff veit’s picture

Before anyone else fixes this: I've fixed it, but I have to bundle up it up into a patch which will happen in the next couple of days sometime.

Jesse Grosjean’s picture

I'm trying to get anonymous purchasing to work with paypalpro. I would love to see what changes you found were necessary to support this. Even if you don't have time to make a patch, just a description of what you did would help. Thanks.

h3’s picture

I noticed too that anonymous purchase was broken and sadly, I really need it :|

When click checkout while logged in I get the shipping and billing address form showing up correctly, but when I try as anonymous user, i get this MySQL error:

user error: Unknown column '7db1579044a049271fd2ce95b754768b' in 'where clause'
query: DELETE FROM ec_tmp WHERE sid = 7db1579044a049271fd2ce95b754768b in /data-2/html/mysite.com/www.mysite.com/includes/database.mysql.inc on line 66.

And only the "Adresse E-mail:" field shows up..

Anyone can help ?

h3’s picture

I just found out that this issue was a duplicate of this one: http://drupal.org/node/34902 wich as a big part of the solution.

To make this feature work, here's what i've done..

First

Like jessethouin said in his reply #3,
on the cart.module at line 801 I've changed

//this
db_query("DELETE FROM {ec_tmp} WHERE sid = %s", cart_get_id());
//to this
db_query("DELETE FROM {ec_tmp} WHERE sid = '%s'", cart_get_id());

Second

thanks to averageyoungman with his reply #2, in address.module within line 125 and 135

//change this
if ($shippable) {
// to this
if ($txn->shippable) {

// AND after 
$billing_form = store_transaction_addresses_form($edit, 'billing');
// add this
$output .= $shipping_form.$billing_form;  

// AND after 
$billing_form = store_transaction_addresses_form($edit, 'billing');
//ad this
$output .= $billing_form; 

now both billing and shipping address form are shows up correctly without any errors, but when I submit it I always get the same error :|

- You need to select a shipping address. 
- You need to select a billing address. 

I'm really getting crazy with this bug

matt westgate’s picture

I've committed the above patch. Please let me know if this issue is resolved.

pz’s picture

That won't fix the issue of the address information not being saved for users that are not logged in, the code assumes there is a address "object" but for users not logged in there never is one.

Timotheos’s picture

Yep it's still messed up.

Basically when an anonymous user is checking out their is no $txn->shipping_address to validate since the anonymous user is using the store_transaction_addresses_form which has a field like shipping_street1.

Sooo... a quick fix is to do something like this...

    case 'validate' :
      <strong>if ($user->uid > 0) {</strong>
        if ($txn->shippable && !$txn->shipping_address) {
          form_set_error('shipping_address', t('You need to select a shipping address.'));        
        }
        if (!$txn->billing_address) {
          form_set_error('billing_address', t('You need to select a billing address.'));
        }
      <strong>} else {
       //One example of some needed validation for anonymous users.
        if (!$txn->billing_street1) {
          form_set_error('billing_street1', t('You must enter a street or how will I ever find you?'));
        }</strong>
      }
      break;

Is anybody else working on this? Seems to me we should make some of the transaction fields required if we're going to use it for anonymous users. I can do this and wrap it in with what I'm doing on http://drupal.org/node/39655

Tim

jeff veit’s picture

Yes - I've fixed anonymous purchases and I think it addresses the issues below, but I haven't built a patch.

Was hoping to do it yesterday, but it's more likely to be Monday now. If anyone wants I'll drop them my code which is 4.6. It has some other enhancements too though, which I should separate into separate patches.

Jeff

jeff veit’s picture

Status: Active » Needs review
StatusFileSize
new13 KB

Here's a patch for this problem. It's been built against ecommerce 4.6. It's tested with PHP 4.4. It needs testing with PHP5. My version of Drupal is a hacked 4.5 so it would be good to test against Drupal 4.6.

Line 192 of store.inc is not one I remember changing, so it's possible that this patch may unintentionally reverse a fix for something else.

This is my first patch submission to Drupal. Let me know if there's a problem with the patch format.

Jeff

jeff veit’s picture

This patch needs a further extension: if there's a shippable product and shipping details are entered, but billing details are not (or vice-versa) then the values of the one should be used for the other. I haven't had time to add this and since that's a less important problem and there's been a bit of clamour for this fix, I won't wait. I'll open another feature request for this change.

sethcohn’s picture

Yes, the patch is in the wrong format...

Among other things, the slashs are the wrong way which confuses patch.

rkerr’s picture

I did a workaround for anonymous people buying products with the Cart, but it actually skips the address section completely.. so that I could send people's cart contents to 2checkout and use their address and payment forms instead.

So, I really only had to change cart.module... but if I'm interested in making sure anonymous users can make purchases so will watch this issue for a bit.

jeff veit’s picture

StatusFileSize
new10.03 KB

Here's a version with slashes the other way. Is that better?

All the comments above still apply; I've used a different patch tool, that's all.

Jeff

vitamin-1’s picture

Still not work.

jeff veit’s picture

Vitamin,

When you say 'Still not work', do you mean that the patch wouldn't apply? That the format of the patch was wrong? Or that you found a bug in the patch.

Thanks,

Jeff

vitamin-1’s picture

Smoothstream,

I took latest e-commerce from CVS with DRUPAL_4_6 tag, then I downloaded your patch.
First of all, it seems to me that patch tries to "downgrade" some pieces of code to previous version.
But anyway, anonymous purchases does not work for me - it give me same error (Please fill shipping address, Please fill billing address - regardless that they are filled or not).

q0rban’s picture

Any update on this? I'm trying to get this to work... Not sure which of the above patches I should try...

pjdevries’s picture

I second that! Need that functionality badly!

vitamin-1’s picture

Here http://drupal.org/node/39655 is the solution.

iokevins’s picture

Thanks for this patch, it solved nearly all my troubles. :)

One note for anonymous purchases, one might want to restrict access to the store/history/0 page (modules/ecommerce/store/store.module) thusly: ;)

175 /*$items[] = array('path' => "store/history/$uid", 'title' => t('order history'),
176 'callback' => 'store_user_history', 'access' => $user_access, 'type' => MENU_CALLBACK);
177 */

Not sure this breaks anything else.

Otherwise anyone in the know seems to be able to publicly access store/history/0 and view customer billing and shipping data. x_x

I have updated http://drupal.org/node/39655 with this bit of news as well.

Kevin

kbahey’s picture

For those who do not know how to patch module, here is a prepatched version of address.module for 4.6.

kbahey’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new4.38 KB

Here is a patch against the latest 4.6 branch, as per Gordon's request.

gordon’s picture

Version: 4.6.x-1.x-dev » master
Status: Reviewed & tested by the community » Active

Thanks all, I have commited this to cvs.

We need to roll this into cvs.

I have activated this again, so that someone can port this change to cvs.

wpd’s picture

Status: Active » Needs review
StatusFileSize
new4.28 KB

Applied patch to cvs version as requested. Can not really tell if it works until more of the ecommerce module is updated.

gordon’s picture

Status: Needs review » Fixed

Thanks I have commited this.

pjdevries’s picture

Title: Anonymous purchase » Invalid 'Browse the CVS repository' link on E-Commerce project page

Being not very well CVS educated, it took me a while to figure out how to access the E-Commerce CVS. The main problem is an invalid link on the E-Commerce project page (http://drupal.org/project/ecommerce). The 'Browse the CVS repository' link points to http://cvs.drupal.org/viewcvs/contributions/modules/ecommerce/ while it should be pointing to http://cvs.drupal.org/viewcvs/drupal/contributions/modules/ecommerce/,

By the way, can anyone explain how to access the 4.6 branche from TortoiseCVS? Updating the branche list only shows HEAD and DRUPAL-3-0 upto DRUPAL-4-2.

pjdevries’s picture

Title: Invalid 'Browse the CVS repository' link on E-Commerce project page » CVS confusion

This time I tried SmartCVS to obtain the latest E-Commerce 4.6 modules and that seemed to work. However, a quick comparison of the retrieved CVS modules with the default E-Commerce 4.6 project download (http://drupal.org/files/projects/ecommerce-4.6.0.tar.gz) shows quite a few changes, many of them having to do with the new 4.7 Forms API. Can anyone explain that? Have I retrieved the wrong Branch/Tag from the CVS and if so, what should I do to obtain the latest 4.6 revision?

q0rban’s picture

Title: CVS confusion » Anonymous purchase

This worked for me (smartCVS):

Make sure you select Tag in the Kind of Revision to get drop down box on the Checkout page. Then in the Tag form field, type "DRUPAL-4-6".. Hope that helps!

Also, be careful when you change the title when posting comments to bugs. It changes the title of the whole bug thread.

Cheers...

wpd’s picture

You can do it from the command line like this:

cvs -d :pserver:anonymous@cvs.drupal.org:/cvs/drupal-contrib login
cvs -d :pserver:anonymous@cvs.drupal.org:/cvs/drupal-contrib co -r DRUPAL-4-6 contributions/modules/ecommerce

You can also use the command cvs status to make sure your files are marked with the sticky tag DRUPAL-4-6.
If not you have the wrong branch.

kbahey’s picture

Status: Fixed » Active

I just discovered that the committed patch for address does not work for registered users on 4.6.

The user cannot get past the /cart/checkout page, and gets the error message: "Please enter a valid email address".

Here is a one liner patch that fixes this (Just a global $user; in the address_checkoutapi() function. it is so small it does not warrant an attachment).

Index: address.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ecommerce/address/address.module,v
retrieving revision 1.16.2.6
diff -u -r1.16.2.6 address.module
--- address.module      3 Feb 2006 03:36:13 -0000       1.16.2.6
+++ address.module      3 Feb 2006 21:57:34 -0000
@@ -48,6 +48,7 @@
  * Implementation of hook_checkoutapi().
  */
 function address_checkoutapi(&$txn, $op, $post_op = NULL, $arg4 = NULL) {
+  global $user;
   if ($txn == 'address') return TRUE;
   $output = '';
gordon’s picture

Status: Active » Needs review

Thanks I have added this.

gordon’s picture

Status: Needs review » Fixed
pjdevries’s picture

Thanks to James and Scott for the pointers on using CVS. It appears I succeeded in checking out a working 4.6 version now.

Sincere applogies for changing the title when posting my comments. I didn't realise it changes the title of the whole thread. It won't happen again.

I have a couple of additional questions concerning the address module. Although I have over 20 years of programming experience, I'm new to Drupal and to PHP and web programming but for my current (and first Drupal) application I want to make a couple of modifications:

1) I want to add a couple of fields to the address form.
2) It seems that only the e-mail address field is mandatory and I would like to have a few more.
3) I would like the red asterisk to show up near all the mandatory fields on the address form.
4) I would like to integrate the address module with the Drupal profile in such a way that an unauthenticated visitor can purchase a subscription and become a registered member all at once, without having to enter any details twice.

Are the above things doable for an unexperienced Drupal/PHP programmer like myself and can anyone give me e few pointers where to start?

coupet’s picture

Do I have to download cvs E-commerce module to obtain latest patch version of address module?

Can I download latest patch address module seperately ?

Thanks, Darly

pjdevries’s picture

What I understand from this thread, is that replacing just the address module should work. Comparing the complete 4.6 E-Commerce package with the CVS version, shows quite some differences in other modules as well. I didn't take the risk and downloaded the complete E-Commerce CVS package which seems to work (as designed).

By the way: can anyone spare the time and energy to help me out with the questions in my previous post?

coupet’s picture

What happens after the user make paypal payment?

Does the user become a member of authenticated user role?
Is the user still anonymous ?

Can we choose how the member is assigned after payment?

Thanks, Darly

AgnesCB’s picture

Status: Fixed » Active

It looks like the patch to address.module to fix checkout for anonymous users (the move from 1.16.2.5 to 1.16.2.7) broke things for authenticated users when the E-Commerce module is set up to require users to be logged in to order.
When reaching the "review and submit your order page" the billing address (I only tested with non-shippable items, shipping address is probably the same) shows up as blank. This is when testing with the latest E-Commerce files for tag 4-6.

Resetting this as active, while noting that downgrading back to release 1.16.2.5 of address.module took me past that bump. Except that now checkout fails silently when placing the order, but I haven't figured out if this is related to this issue or is something different...

AgnesCB’s picture

Version: master » 4.6.x-1.x-dev

This is currently against 4.6, as HEAD has moved to 4.7.

AgnesCB’s picture

Status: Active » Needs review
StatusFileSize
new1.46 KB

Here is a patch that fixes things for logged users and shouldn't break anonymous purchases, although I haven't tested those.
Needs to be reviewed by a better PHP programmer than I am (was it a scope issue?).

gordon’s picture

Looking at this patch, there is no change to the code. Basically the patch removes 1 line and then duplicates that same line twice.

This think this was a problem on you system that you accidently fixed.

AgnesCB’s picture

Priority: Critical » Normal

I know. None of this makes sense.

I got to this place by rolling back to the latest version that worked in CVS, and then applying differential changes. Removing the last change (the one that moved that line out of the if statement) solved the issue in my environment: the address selection combo was showing again. Putting it back in both places got me a duplicate. Having it outside of the if? Nothing. I added it back inside the else statement to make sure there wouldn't be any changes for anonymous (I don't use about anonymous purchases, other people might).

I will wipe out my test environment and start from scratch with a clean/empty Drupal and E-Commerce install... Downgrading this in the meantime.

jeff veit’s picture

Status: Needs review » Active

I finally have the time to get back to the anonymous purchase problem. I'm hoping to whack this today.

I've done a series of tests, and the results are listed below.

I'm using Drupal 4.6 download version, together with ecommerce 4.6 head. Everything is standard: it's a new set up.

Ecomm set up: I have a tangible item and a non-tangible. I haven't tried anything with grouped items. The ecomm module lets you set the order of checkout screens. I am only using the default - address first, then payment, then cart, although a brief test suggests that the problems are there for other screen ordering too.

Firstly using cash on demand as the only payment option, with anon purchase:

  • When you get to the screen asking for your email address, and the shipping and billing address, with COD, you should only have a shipping address.
  • If you have non-tangible items, perhaps you shouldn't be able to choose COD. If there are no other payment options, you should get an error message explaining why. (This is debateable: what if the item is a service - a car wash by hand where someone comes to you.) What do other people think?
  • When you get to the screen with addresses, if you don't enter a shipping or billing address, you don't get an y error messages. You should.
  • When you get to the screen with the addresses. Usually, if you enter a correct email address, but no shipping or billing address, you are returned to the same screen, losing the email address along the way. If you fill in the email again, but no other addresses, you get to the purchase review screen. Fantastic! COD with no address. This is wrong. Above, I said that it usually happens. I've seen other behaviour but haven't narrowed down the cause.
  • When you get to the review screen, if you dwecide to change the number of items you lose all the address information you've already entered, and you end up retyping it. This is mentioned in http://drupal.org/node/39655 'Change of address on final review can bypass tax rules' too.

Now using paypal with anonymous purchase:

  • There's no validation of address details and after entering your email address you move straight on to the review page. This problem is mentioned in http://drupal.org/node/39655 too.
  • You enter your address details and these aren't passed to Paypal. May have to do with the default Paypal set up.

General:

  • It's fantastically annoying for people not in the USA to see 'state & zip code'. At the least we should use the more neutral: 'State/Province/County/Canton/Region' and 'Zip/Postal Code' although even this assumes that the US is the default.

If anyone else knows of any other problems with anonymous purchase, please list them here.

AgnesCB’s picture

StatusFileSize
new1.83 KB

If you have non-tangible items, perhaps you shouldn't be able to choose COD.

I disagree.

We use the E-Commerce module for a local non profit that sells memberships through its website. While Paypal makes our life easier, we have more than a few members who are not very tech savvy and still prefer to pay by check. To us non-tangible + COD is a necessity (even if it is not actually check on delivery but rather send your check and your order will get processed manually).

jeff veit’s picture

Thanks, that's very useful to know.

jeff veit’s picture

There are two related conversations going on: http://drupal.org/node/41136 and http://drupal.org/node/14604

I know that this is anonymous purchase bugs, and that's what I'm working on, but it's the most complete conversation that I've found so far about workflow, so I'm adding this bit into the mix from 41136

--------

The payment modules should have:
- the ability to check that the info that has been submitted is appropriate for that payment method
- the ability to specify the address format required

Actually, it might not only be the payment modules that should be able register address requirements, there's a note somewhere that says that tax modules have some address requirements too for GST (General Sales Tax).

The address module should communicate with the payment method modules to get the definitions of requirements, and collect the specific details for that payment type.

The workflow order should be fixed to:
payment type screen, addresses, checking

This order allows you to collect only the data required for that particular payment type.

The address module should provide a mechanism to define extra fields that should be collected.

What holes can you find in these proposals?
-------

jesse_idc@civicspacelabs.com’s picture

I have tried patching address.module,v 1.16.2.5 2005/12/02 with the patches above, including trying Khalid's pre-patched module, running drupal 4.6. While this superficially allows anonymous users to pass the "enter shipping/billing info" step, the entered billing/shipping info is not passed along to the rest of the checkout process. Confirming the order results in a blank screen (I am using PayPal as the sole payment method).

I've looked at this thread, and http://drupal.org/node/39655 and found no solution. Do I have to wait for 4.7 to fix the anonymous purchases issue, or are there other files within ecommerce that I need to edit in order to make this work?

jesse_idc@civicspacelabs.com’s picture

Ignore my last comment - it turns out I did indeed need to update another file. I needed to get a more recent copy of the cart.module file, which I found here: http://cvs.drupal.org/viewcvs/drupal/contributions/modules/ecommerce/car...

q0rban’s picture

Well, I thought I anonymous purchase working using the above patch, until I had an anonymous user purchase a file. How does an anonymous user access their files? And if they can't, shouldn't there be a check to make sure that anonymous users who try to purchase a file must first create an account?

cheers..

coupet’s picture

I have similar issues to q0rban. I think new user should require only the following (username, password and email) then they will be able to download files or have access to content as defined by roles.

Scenario (1) for generic product - no shipping infromation required
-------------------------------------------------------------------
1. Anonymous user 2. Not a new member (no information is obtained from user) 3. Paypal payment 4. Address obtained manually thru Paypal for processing

Scenario (2) for generic product - no shipping infromation required
-----------------------------------------------------------------
1. Anonymous user 2. Becomes a new member (obtain username, password, email from user) 3. Paypal payment

Thanks, darly.

wpd’s picture

The checkout logic should not branch for anonymous users.
Proposed flow: (anonymous user)
1. Hit Checkout Link
2. Display Login box AND ask for email address
3. IF user Logins then go to step 5.
4. Create account for new user
5. Proceed with normal checkout (addresses, payment, etc...)

This wil simplify the logic in the checkout process. The key to this is making the creation of the account a normal part of the checkout not an annoyance to the user. (Although creating an account should be less trouble than buying a file they can not download ;))

New code will be need for step 2 and 4, but that should be adaptation of existing drupal code.
Note: this is how amazon.com deals with purchases.

Agree/Disagree? I have not looked at coding this because I do not want to waste my time if nobody likes the idea.

q0rban’s picture

The checkout logic should not branch for anonymous users.
Proposed flow: (anonymous user)
1. Hit Checkout Link
2. Display Login box AND ask for email address
3. IF user Logins then go to step 5.
4. Create account for new user
5. Proceed with normal checkout (addresses, payment, etc...)

This wil simplify the logic in the checkout process. The key to this is making the creation of the account a normal part of the checkout not an annoyance to the user. (Although creating an account should be less trouble than buying a file they can not download ;))

New code will be need for step 2 and 4, but that should be adaptation of existing drupal code.
Note: this is how amazon.com deals with purchases.

Agree/Disagree? I have not looked at coding this because I do not want to waste my time if nobody likes the idea.

I agree, but one of my clients would disagree. For some reason or another, anonymous purchasing is dear to his heart, which leads me to believe that many customers might feel the same; ie, that it is a hassle to have to register before making a purchase.

The only thing barring anonymous purchase from being completely possible with e-Commerce seems to be the 'file' product issue. For those of you possibly not aware, after files are purchased, they are available under a 'my files' menu item associated with the current user. A database call is made which looks up the transactions made by the current user (uid), and associated files are listed in this fashion: http://www.example.com/store/myfiles/1/download?file=filesdirectory/mydownloadfile.blah. The '1' you see there is the uid. This protects (prevents) any anonymous user from accessing the files. This is a good thing, and IMO we do not want to bypass it, for security reasons.

In a conversation with smoothstr we brought up the idea of having a forced registration for certain product types, configurable in admin. The main product type in mind, obviously, is the 'file' type. Smoothstr suggested the possibility of certain (tangible) product types that should require login such as guns or the like. Does anyone else foresee any other possible product type that would require login before purchase? Otherwise, my vote is to force login for 'file' products and let anonymous purchases be made for all other purchases (contingent on the anonymous purchase setting in admin).

cheers,
q0rban

coupet’s picture

I think simplifying registration and payment process for the new user is the objective.

Files download may requires being a member.

Also, the site might be selling membership access to content, then address is not required.

I think the minimum should be required to obtain payment and be registered to get access to files download or view content.

Also, logintoboggan improves Drupal's login system.

Thanks, Darly

sime’s picture

Component: address.module » address
Status: Active » Closed (won't fix)

We are not supporting 4.6 now. Please re-open if any problems.