This project is not covered by Drupal’s security advisory policy.

Repeat customers are your best customers; you can rely on them to keep coming back to your store so long as you provide the goods or services they need. They are a steady revenue stream, an easy sell. But to quickly close the sale you need to make it easier for them to find and purchase more of the same stuff they've ordered previously.

This module lets your customer (or you, the admin) duplicate a previously placed order. It works by modifying the user order history page (e.g. user/4/orders) to display a "Re-Order" button for each previous order. The user can click on the link to have all the items from that previous order added to his or her current cart. Items added to the cart in this manner will have the current price, but will otherwise preserve all the same attributes as in the previous order.

When stock tracking (using the Inventory API) is enabled, products are only added to the current cart if they are in stock.

To Use:
Install uc_reorder module. Enable it at admin/build/modules.

Implementation details:
There is no way to hook into the Ubercart core uc_order_history() function to change what is on the order history page. So to add the Re-Order button I had to employ a trick. The trick is to override the user/#/orders menu, defined in uc_order_menu(), to call my uc_reorder_order_history() function instead of the core uc_order_history() function. Note that in the Drupal 6 version this override is considerably easier, because of the new hook_menu_alter(). In the Drupal 5 version this involved defining a dynamic menu override in uc_reorder then ensuring uc_reorder loads after uc_order. Because of this trick, you can't have uc_reorder and uc_tracking enabled at the same time.

The code is commented throughout. Comments and enhancements welcome.

Revision notes:
A change in Ubercart versions 6.x-2.0-beta6 through 6.x-2.0-rc2 renamed the menu path for the user order history. As a result, this module will not work properly with those versions. Please ensure you are using Ubercart 6.x-2.0-rc3 or higher.

A change in Ubercart 6.x-2.0-rc5 modified the way attribute options are stored in an order, breaking this module. Use the 6.x-1.1 release of this module for Ubercart 6.x-2.0-rc3 and below, and use the 6.x-1.2 release of this module with newer versions of Ubercart.

Project information

Releases