Suggest what user could buy if he already has something in the cart

The thing you’re describing is a recommendation engine; more specifically collaborative filtering. It’s the heart of Amazon’s “people who bought x also bought y” feature, and Netflix’s recommendation engine.

It’s a non-trivial undertaking. As in, to get anything that’s even remotely useful could easily take more than building the ecommerce site in the first place.

For instance:

  • you don’t want to recommend items that are already in the basket.
  • you don’t want to recommend cheaper versions of the things that are already in the basket.
  • you don’t want to recommend items that are out of stock.
  • you don’t want to recommend items that are statistically valid, but make no sense (“hey, you bought nappies, why not buy beer?” – there is a story that in supermarkets, there is a statistical correlation because dads go out at night to buy nappies and pick up a six pack at the same time).
  • you do want to recommend items that are in a promotion right now
  • you don’t want to recommend items that are similar to items in a promotion right now

When I tried a similar project, it was very hard to explain to non-technical people that the computer simply didn’t understand that recommending beer alongside nappies wasn’t appropriate. Once we got the basic solution working, building the exclusion and edge case logic took at least as long.

Realistically, I think these are your options:

  • manually maintain the related products. Time consuming, but unlikely to lead to weirdness.
  • use an off-the-shelf solution – either SaaS or include a library like R which supports this.
  • recommend (semi)random products. Have a set of products you want to recommend, and pick one at random – for instance, products on promotion, products which are in the “best seller” list, products which cost less than x. Exclude categories that could be problematic.

All those options are achievable in reasonable time; the problem with building a proper solution from scratch is that everyone will measure it against Amazon, and they’ve got a bit of a head start on you…

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)