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.
6 年 前
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.
6 年 前
Checkout attribute will retain its value if you register after adding products as gust but it will not retain it value if you login
6 年 前
That's the problem. If user is shopping as a guest and logs in during checkout, all of their checkout attributes are lost.
6 年 前
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'
6 年 前
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.
6 年 前
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);
6 年 前
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.
6 年 前
Thanks a lot! I've just created a work item
6 年 前
And fixed. Thanks again
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.