osCommerce Previously Purchased

By | June 15, 2010

Contacted today by someone who wanted the ability to show customers what they have already purchased (whilst browsing the site). In other words display a “You have already purchased this” warning message at the top of the product info page etc etc.

The first thing to know is that we need to have the customer logged in as without their customer ID there is no way to grab the needed information.

The next thing to know is that we need to join together two database tables; orders & orders_products

It’s really very straightforward;

1. customer logs in
2. we join the orders and orders_products table and grab the needed product IDs of the already purchased items
3. we place these into an array
4. we check the product Id whilst the customer is browsing the store, against the array. If the numbers match, show the message

All in all, this was 10 minutes work to get a viable solution. Of course, it could be cleaned up and made better (eg, show the “you’ve bought” message elsewhere such as the shopping_cart page, or in the products_new module etc), but for now all that is needed is the message on the product_info.php page, and it works OK.

One thought on “osCommerce Previously Purchased

Leave a Reply

Your email address will not be published.