laravel-cart-manager icon indicating copy to clipboard operation
laravel-cart-manager copied to clipboard

Remove specific product in all users carts

Open berkayk opened this issue 5 years ago • 1 comments
trafficstars

Is your feature request related to a problem? Please describe. Let's say a product is no longer available. It has to be removed from all carts immediately so that users' won't buy those items.

Describe the solution you'd like From the documentation, I cannot find how to update all users' carts with the available methods. Does cart() method apply to all users or just the current user?

Describe alternatives you've considered I tried fetching all carts that include the given product id. After that, I check the carts but I can't find a way to remove and update the totals etc.

berkayk avatar Dec 23 '19 09:12 berkayk

Hi Berkay,

This is a practically possible use case. Thanks for pointing out. Thoughts:

  1. cart()` method is used for the current user's cart only/

  2. Totals are updated automatically when you use any of the documented methods.

  • You can find the index of the product in the cart first and remove it using the index.
  • Maybe, we should provide a to do the re-calculations and update cart totals.
  1. We should also develop a solution in the package to remove unavailable products from all carts. But, it has to work in different drivers (Database, Session) as well.

gauravmak avatar Dec 30 '19 04:12 gauravmak