odoo-shopinvader icon indicating copy to clipboard operation
odoo-shopinvader copied to clipboard

[16.0] Anonymous cart?

Open simahawk opened this issue 11 months ago • 6 comments

In v14 you could create a cart for an anonymous user by using backend.anonymous_partner_id. The cart would then be swapped the real customer upon login.

What's the plan for v16?

CC @lmignon

simahawk avatar Mar 05 '24 09:03 simahawk

@lmignon gentle ping :)

simahawk avatar Mar 08 '24 10:03 simahawk

@simahawk I'm back from holidays, I'll try to get back to you later this week.

sbidoul avatar Mar 11 '24 14:03 sbidoul

Hi @simahawk,

If you look at the demo app (#1364), there is a _get_cart_app_dependencies_overrides function that is used to set the right authentication mechanism (i.e. auth_jwt_authenticated_or_anonymous_partner_autocreate) on the cart routes.

That mechanisms either authenticates a known partner, or creates an anonymous partner and sets a cookie to identify it (see the shopinvader_anonymous_partner addon).

In v14 we had a single partner shared by all anonymous carts. With the new API, we create a new anonymous partner for each visitor that populates the cart: it should be simpler in the end, for instance when different anonymous partners are from different countries or such.

The last missing part is the conversion of the anonymous partner into a known partner (and transfer of the cart) upon signin. @qgroulard is working on it these days. The plan for that is in https://github.com/shopinvader/odoo-shopinvader/issues/1428#issuecomment-1843325040.

sbidoul avatar Mar 14 '24 15:03 sbidoul

See also https://github.com/shopinvader/odoo-shopinvader/issues/1368 for the whole authentication story.

sbidoul avatar Mar 14 '24 15:03 sbidoul

@sbidoul thanks for the summary and the pointers! I'll have a look :)

simahawk avatar Mar 15 '24 10:03 simahawk

@simahawk Please have a look at https://github.com/shopinvader/odoo-shopinvader/pull/1523. You'll see what we have done for the jwt authentication. The management of the anonymous partner and cookie and the transfer of the carts are done in dedicated modules, hence similar logic can easily be implemented for other authentication mechanisms.

qgroulard avatar Apr 03 '24 09:04 qgroulard