shopinvader / odoo-shopinvader

Odoo Modules. Sorry Magento, Shopinvader is coming
GNU Affero General Public License v3.0
121 stars 104 forks source link

[16.0] Anonymous cart? #1510

Open simahawk opened 8 months ago

simahawk commented 8 months ago

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 commented 8 months ago

@lmignon gentle ping :)

sbidoul commented 8 months ago

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

sbidoul commented 8 months ago

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 commented 8 months ago

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

simahawk commented 8 months ago

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

qgroulard commented 7 months ago

@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.