1

In Commerce, a User (or guest with an email address for that matter) can have multiple carts (or unfinished orders). So we need to get the most recently active one. Something like this should work: $query = Order::find(); $query->id($whateverId); // you could also use $query->email $query->isCompleted(false); $query->orderBy('dateCreated DESC'); ...


1

You can use a console command to kick off a garbage collection run. This will remove any customers not associated with a user or cart/order. It will do other things too. docs for craft 3x https://craftcms.com/docs/3.x/gc.html


1

Maybe The purchase Patterns Plugin Could Solve your problem. https://github.com/ethercreative/purchase-patterns/blob/v1/README.md


Only top voted, non community-wiki answers of a minimum length are eligible