bossanova808 / CommerceRegisterOnCheckout

ARCHIVED: SEE README Allow user registration during Craft Commerce V1 checkouts.
Other
33 stars 3 forks source link

Duplicated entry on craft_commerce_customers table created #3

Closed ax2000 closed 7 years ago

ax2000 commented 7 years ago

Hi Jeremy,

First of all, thanks for this handy plugin. I'm experiencing an issue where it seems that 2 different entries are created in the "craft_commerce_customers" table.

The first entry seems to be the default craft behaviour and the "Last Billing Id" and "Last Shipping Id" get mapped to this customer.

The second entry seems to be the one created by the CommerceRegisterOnCheckout plugin and the UserId gets map to this entry.

Everything else seems working as expected where and the user gets created and mapped to the second entry although it doesn't have any Billing or Shipping info mapped to it.

Im using Craft CMS 2.6.2959, Commerce 1.2.1334, and Commerce Register on Checkout 0.0.3.

I also have Commerce Widgets 1.0.3 and Commerce Stock Notifier 1.0.0 but they shouldn't be affecting the process.

Please let me know if you need any more info to try and replicate the issue.

Thanks heaps, Alberto

bossanova808 commented 7 years ago

CommerceRegisterOnCheckout does not create any entries in craft_commerce_customers - the only table it creates records in is commerceregisteroncheckout.

I see quite a few duplicates in that craft_commerce_customers table on my live site too, which is a bit odd, but I don't know what's happening in there at all really - I presume it creates a new record as the customer becomes a registered user - with the new user id...not sure why it keeps the old record, or doesn't update the current one - but I don't think this has anything to do with my plugin, and doesn't seem to cause actual issues that I can see.

I'd ask Luke in Slack, or post on SE about the duplicate records, but I'm quite sure my plugin isn't making the records as such....

ax2000 commented 7 years ago

Thanks for the prompt reply Jeremy.

It looks that it might be something related with Craft's creation of the user then. I'm going to perform some other tests myself here to see if it's any difference when creating the user account manually after the checkout.

I'll also ask in Slack/SE to see if anyone else can help there.

Cheers

bossanova808 commented 7 years ago

I'm chatting with Luke about it.

It's not an issue, really. It just means the new user doesn't have a default shipping/billing in place until their next order...will see if we can work it out.

ax2000 commented 7 years ago

Ok, thanks for that. Yes that seems to be the case. Please let us know how you go with it. I'll post anything else we might find out

ax2000 commented 7 years ago

Hi Jeremy,

Just FYI:

I can confirm that same behaviour happens if the purchase is done by a guest user and then the user registers using the default Craft User Registration Form with the same email address. (All of this with the CommerceRegisterOnCheckout plugin disabled)

Two different entries are created in the craft_commerce_customers table, first one has the address mapped to it but no user and the second one has the userId mapped but no addresses.

As you said, it looks like a Craft thing.

bossanova808 commented 7 years ago

Yep, it is.

I'm almost ready with a fix for it with this plugin though....just doing some testing now, then need to do the db migration for any upgraders.

bossanova808 commented 7 years ago

Should be solved in 0.0.4 (that is- the second record will now contain the address Ids, but there will still be two records - Luke mentioned he will later add some cleanup code, but there's no issue with having them there for now)