djaodjin / djaodjin-saas

Django application for software-as-service and subscription businesses
Other
564 stars 124 forks source link

Create a page to view a user cart and remove items from it #130

Closed smirolo closed 11 months ago

smirolo commented 6 years ago

The page in views.billing.CartView is used for checkout/payment. There needs to be a similar page whose purpose is just to view/modify any User cart. The API end points to add or remove items from a cart are api.billing.CartItemAPIView and api.billing.CartItemDestroyAPIView respectively.

knivets commented 6 years ago

"view/modify any User cart" -- does "any" mean that we can pass an organization parameter via url and retrieve a cart based on this parameter? Also, what can be modified exactly: is this about deleting items or changing quantities of items, etc? And this should be a regular view not an angular controller which makes requests to API, correct?

smirolo commented 6 years ago

The primary request for this functionality is for managers to be able to see and manage abandoned carts. It is a manager dashboard feature. Details:

  1. Carts (ie. CartItem objects) are per User (anonymous or authenticated) so it makes sense to pass a username in the URL. Note: I don't think we currently keep carts (as CartItem in the db) for anonymous users, mostly because with so many bots hitting everything they can, unauthenticated requests do not provide meaningful information.

  2. Carts should be fully manageable (deleting items, changing quantities, etc.) in order to give enough flexibility to customer support staff.

  3. Any feature (this one and others) should always be implemented using the API end-points. For historical reasons some features (like update Organization) are not yet doing so but intended to.

For customer-centric, adding a delete button that calls the api.billing.CartItemDestroyAPIView API end-point (see https://github.com/djaodjin/djaoapp/issues/6) is enough.

knivets commented 6 years ago

1) I see that the angular code expects the view to have an organization context variable and it is taken from OrganizationMixin which queries it via url, however by using username in url we are not able to get the organization. Should I change the angular code to work without organization?

knivets commented 6 years ago

the other thing is if we're going to make a vue.js rewrite, what's the point of investing time in this feature if it gets rewritten soon anyway?

smirolo commented 6 years ago

There is a UserMixin that reads username from a view kwargs. I believe the angularjs code itemsListCtrl could work with either a username or organization. The purpose of doing the work now is to help support teams Today. I agree though that if it takes more than 4 or 5 hours to get the feature done, we should wait for the vue.js rewrite. Thanks.

smirolo commented 5 years ago

Time to get back on this. Add an url page in broker.py called /billing/carts/ that displays the CartItem which are active and allow to delete them.

smirolo commented 11 months ago

PR #276 addresses this item. The /api/cartitems/{id} URL is using the primary key of the CartItem in the database. It is acceptable as long as only brokers can view/update cartitems.