Checkout Attributes are lost after login state changes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Il y a 6 ans
The following is happening on v3.90

Steps to recreate:

1) Setup some Checkout Attributes on the Checkout Page.  In my case it is "Invoice Number".  It is required.

2) AS A GUEST, add a product to your shopping cart.

3) On the Shopping Cart page, populate the Checkout Attribute (ex: Invoice Number) and the select "Continue Checkout"

4) On the Welcome screen, login as an existing user

5) When returned to the Shopping Cart page, notice that the Checkout Attribute (ex "Invoice Number") is erased.


The desired behavior is that checkout attributes persist after a user logs in or registers.
Il y a 6 ans
Checkout attribute will retain its value if you register after adding products as gust but it will not retain it value if you login
Il y a 6 ans
That's the problem. If user is shopping as a guest and logs in during checkout, all of their checkout attributes are lost.
Il y a 6 ans
nopCommerce save customer specific checkout attributes in 'GenericAttribute' table based on previous checkout attribute values. When you add products as guest and login in checkout page guest user customer Id and logged in user customer Id will change, so you will not retain customer attribute values after login. In case you want to retain those values add custom code to 'public virtual void MigrateShoppingCart(Customer fromCustomer, Customer toCustomer, bool includeCouponCodes)' function in '\Libraries\Nop.Services\Orders\ShoppingCartService.cs' file. In this function get checkout attributes values of 'fromCustomer' and assign to 'toCustomer'
Il y a 6 ans
If you need code add below 2 lines of at the end of 'public virtual void MigrateShoppingCart(Customer fromCustomer, Customer toCustomer, bool includeCouponCodes)' function in '\Libraries\Nop.Services\Orders\ShoppingCartService.cs' file. Let us know if you need more help.
Il y a 6 ans
Sorry I missed code lines in the previous post

var checkoutAttributesXml = fromCustomer.GetAttribute<string>(SystemCustomerAttributeNames.CheckoutAttributes, _genericAttributeService, _storeContext.CurrentStore.Id);
            _genericAttributeService.SaveAttribute(toCustomer, SystemCustomerAttributeNames.CheckoutAttributes, checkoutAttributesXml, _storeContext.CurrentStore.Id);
Il y a 6 ans
Thank you so much!!!!  I'll give this a shot. It would have taken me hours to track this down.

I still think this should be OOTB however. It's perceived as a functional defect resulting to the techinal implementation you described.
Il y a 6 ans
Thanks a lot! I've just created a work item
Il y a 6 ans
And fixed. Thanks again
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.