Reorder button

Contrib type: 
Module
Status: 
Uploaded for testing
Moderation: 
Not ready for moderation

Downloads

Latest version: 
1.0
Compatibility: 
Ubercart 1.x

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:
The proper place to put these mods is in uc_order, but rather than hack core I used the same trick as in my uc_tracking module. Because of that, you can't have uc_reorder and uc_tracking enabled at the same time. 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.

The code is commented throughout. Comments and enhancements welcome.

Know Bugs:
Doesn't work quite right with Product Kits. The kit will get added to the cart, so it seems to work, BUT many database errors will be printed. Not sure what's going on there...


Related threads: 
PreviewAttachmentSize
uc_reorder-1.0.tar.gz9.15 KB
pcambra's picture
Offline
Bug Finder
Joined: 01/23/2008
Juice: 251
Order history priority and Re Order Button

Hi

I wasn't able of making this module work until i changed its weight, it must be executed after the uc_order module, so I have added in the install hook this code:

function uc_reorder_install() {
  $sql = "SELECT weight FROM {system} WHERE name = 'uc_order'";
  $weight_order = (int)db_result(db_query($sql)) +1;
  $sql = "UPDATE {system} SET weight = %d WHERE name = 'uc_reorder'";
  db_query($sql,$weight_order);
}

And, I've had problems with the Re-Order button, and a simple link is fine for me so I've substituted this line
array('data' => drupal_get_form('uc_reorder_reorder_form', 'user/'. $user->uid .'/orders/reorder/'. $order->order_id)),
For this:
array('data' => l('Re-Order', 'user/'. $user->uid .'/orders/reorder/'. $order->order_id)),

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3286
Re: Order history priority and Re Order Button

Thanks, I've put that code in the next version to ensure uc_reorder always gets loaded after uc_order. (I think it should have been loaded after by default, because the execution order is alphabetical, but evidently that isn't always true...)

<tr>.
Alaska's picture
Offline
Joined: 10/16/2007
Juice: 1434
Missing Reorder Product List

TR:

Seem to only find this button (see PNG) on the page in drupal/cart/checkout field and not a listing of products purchased. Using Uber 1.6. However, the cart is setup so that no pricing is displayed. The customer receives an invoice and the firm receives a copy of that information. i.e. customer and admin templates in uc_order/templates. Nothing more.....

Thus shipping, shipping quotes, fulfillment and payment modules have not been installed. Perhaps without these additional modules not being installed is causing the issue.

However, just the addition of the button to add an existing address is a huge plus. Something that all carts should have.

AttachmentSize
saved_addresses.png 9.9 KB
TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3286
Re: Missing Reorder Product List

I'm a little confused by your post. This module adds a Reorder button to the user's order history page at user/#/orders. It doesn't do anything to cart/checkout. Your image looks like a normal part of the Ubercart cart/checkout page.

When one of the Reorder buttons at user/#/orders is selected, it will add the items from that previous order into the current cart. At cart and cart/checkout, your cart should now contain the reordered items plus anything else that was already in the cart.

<tr>.
Alaska's picture
Offline
Joined: 10/16/2007
Juice: 1434
Confused

Guess that makes us both confused.

Had one setup on a Wamp local host server with reorder installed. The button above the address field was added when reorder was installed.

Then on a 2nd setup on another computer with Wamp there was no button above the address box. When reorder was installed it showed up.

Not a bad thing, but now wounder where it came from when reorder is added.

Have never seen that addition on my other older site so thought that it was something that reorder added. Maybe not!

UPDATE

Yes, there is a reorder button on user/4/orders. Changed the status of the order from pending to completed.

When clicked there are no additional items placed in the cart nor does it take you to the cart. The button returns you to the previous page user/4/user/4/orders/reorder/62. (seems that there are a double set of user/4 listed)

If I take out one set of user/4 the cart is displayed with the reordered items showing. Now, what to modify to dump the extra info that is in the URL. (note: my drupal folder is called drupal-5.12 and not durpal - perhaps not an issue - this is being run as localhost on a Wamp server)

Alaska's picture
Offline
Joined: 10/16/2007
Juice: 1434
URL

The displayed URL for My Order History is:
http://localhost/drupal-5.12/4/orders

When the reorder button is activated the URL becomes:
http://localhost/drupal-5.12/user/4/user/4/orders/reorder/64

Seems that this form action is called for in line 180 or so in the reorder module.
$href

Any ideas on what should be changed to remove the double generated user/4?

Alaska's picture
Offline
Joined: 10/16/2007
Juice: 1434
Solution

See solution at:

http://www.ubercart.org/forum/support/7630/reorder_button_dispalys_incor...

Thanks TR for solving this issue.....

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3286
Moved to Drupal.org

This module is now hosted on Drupal.org at http://drupal.org/project/uc_reorder

Please post any issues or support requests on the above project page, not here.

<tr>.