Wish list/gift registry module

Posts: 46
Joined: 10/02/2007
Bug FinderGetting busy with the Ubercode.

I'm beginning work on a module to provide wish list/gift registry functionality to Ubercart. I'd appreciate comments or questions about its design so that it can be a useful contribution to the Drupal community.

As I see it, the module would add these features to Ubercart:

1. Users could save products to wish lists as they now add products to shopping carts. An 'add to wishlist' button would be added in the same places as the 'add to cart' button appears. Users could also view and modify their wishlists as they view and modify the shopping cart.

2. Users could send e-mails notifying others about their wishlist.

3. Wishlists could be located by searching for the user by name (also, by link from the notification e-mail). When an item from a wishlist is purchased, the customer and time are recorded. The customer can send the gift to either the wishlist owner's address or to himself.

I anticipate reusing some of the uc_cart code, and using a database schema like:

{uc_wishlists}
wid (int) -- wishlist id
uid (int) -- user id
title (text) -- wishlist name
date (int) -- event date/deadline

{uc_wishlist_products}
wid (int) -- wishlist id
nid (int) -- node id of product
qty (int) -- requested quantity
changed (int) -- timestamp of last update
data (text) -- product data, including attributes
purchase (text) -- purchase data for each in total quantity, including user, timestamp

I'll update this forum topic with progress on the development. I'd appreciate any suggestions or advice on best implementing this design.

Posts: 4256
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

detour,

This project sounds great. Honestly, I sometimes feel like anything we can do to follow in Amazon's shoes is a good move. (Ok, so maybe not everything. Eye-wink)

Your idea seems to be right on, and I've got a little bit of feedback and some questions about potential problems.

First, the ideas: this may be outside the scope of your module, but it would be cool for users to have a place in their user account where they could copy/paste HTML to link to their wishlists from blogs or wherever else. Administrators could define either a text message or an image on their server to be used as the link.

The more important idea was the need for anonymous users to be able to keep wishlists. You can use a wishlist ID system similar to the cart, in that the session ID is the ID for anonymous users. While they wouldn't have all the features, they could still build up a wishlist and e-mail it to themselves or their friends. (Obviously would need some flood checking to make sure it doesn't get hijacked by spammers.)

One problem I thought of was how to handle mailing products to the owner of the wishlist. Currently, users who have not checked out an order will not have any address information stored in the database. Your module would either need to let people attach an address to a wishlist or we'd have to rework the way addresses are being stored in core... Obviously, the first option will be the easiest at the moment, since it doesn't depend on me being available to collaborate on the changes. I'm up for reviewing the system, though.

You know... I feel like I had something else to comment on, but maybe it was just the anonymous user idea. If I think of it, I'll post back here.

I'm excited to see what you come up with. aswalla just released http://www.magmaweb.com yesterday and probably would've loved to have some native wishlist support. (see here)

Posts: 78
Joined: 08/09/2007
Bug Finder

I vote for having a dedicated table for user information like name, company, address, address name. The customers need to be able to edit the ship-to locations. Kinda like amazon :-/ Anonymous users could be allowed to create a wishlist similar to how they create a shopping cart, except they would see a "save wishlist" button to create a user account and save contact info.

--

Biodiesel * (ubercart + drupal) = Sundays Energy

Posts: 45
Joined: 10/07/2007
InternationalizationizerNot Kulvik

i second the html code idea.

with regards to the anonymous wishlist. i feel making it mandatory for the user to subscribe to the site is best. that way we can avoid spam, and i dont know why but i get the feeling that this feature request might be abused somehow.

thanks

detour: whats the status of the module ? is it usable yet?

--

Mohammed Arafa

Posts: 46
Joined: 10/02/2007
Bug FinderGetting busy with the Ubercode.

I've finished an initial version of the wish list module, and I'd appreciate suggestions from the community on directions for future development.

To install it:
1. Download the uc_wishlist.tgz attachment to this comment.
2. Extract the contents into the Ubercart directory. (This will create a uc_wishlist subdirectory).
3. Patch uc_cart.module with included update: From the uc_cart directory, run patch -p0 < ../uc_wishlist/uc_cart.patch

This has been tested with Ubercart Alpha 7d, 7e, and a recent Bazaar version.

These are some issues that came up in development:

I wanted to make the module as self-contained as possible so that little patching of other Ubercart modules would be required. For example, I added the 'add to wish list' buttons next to the 'add to cart' buttons by altering uc_product_add_to_cart_form, catching the form, and resubmitting it if the intended operation was to add to cart. However to automatically add the recipient's address to the shopping cart checkout form, it seemed preferable to make a patch for uc_cart rather than creating an alternate handler.

The number of products purchased from a user's wish list is tracked through a uc_order hook. When an item is added to the shopping cart from a wish list, extra information (the wish list and wish list product id) is added to the data array. Then when an order is completed (when the order status becomes pending) the order is scanned for items that came from a wish list. If any are found, their corresponding wish list products are updated, adding the order id, order product id, user id, and timestamp to the purchase field in the wish list products table.

I would like to see a central way of handling and accessing address data. I had to leave a fair amount of panes, css, and js code from uc_cart behind to provide this module's own address interface.

The module introduces two new tables (schemas updated from above):

{uc_wishlists}
wid (int) -- wish list id
uid (text) -- user id or session id
title (text) -- wish list title
date (int) -- event date/deadline
address (text) -- delivery address

{uc_wishlist_products}
wpid (int) -- wish list product id
wid (int) -- wish list id
nid (int) -- product node id
qty (int) -- quantity wanted
changed (int) -- timestamp of last modification
data (text) -- serialized array of product attributes and data
purchase (text) -- serialized array of purchase records

AttachmentSize
uc_wishlist.tar.gz14.96 KB
Posts: 129
Joined: 08/14/2007
Uber DonorBug FinderEarly adopter... addicted to alphas.Cool profile pic award.Internationalizationizer

Excellent work detour Smiling I'll give it a go.

______________
Best regards,
Thomas Kulvik
Ny Media AS
www.nymedia.no

Posts: 4256
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

A quick thought on the need for a patch... instead of doing that, you can really just use hook_form_alter() for the checkout form. If the conditions pass (no existing order - check $_SESSION['cart_order'] - and items only come from one wishlist), then set the default values to the address fields for the wishlist.

About the address handling, I've been thinking about this some more and would be open to discussing it if you started a thread in the development forum. I just don't have any good ideas on design/implementation at the moment. Well, I have some, I just don't know if they're good or not. Eye-wink

Posts: 46
Joined: 10/02/2007
Bug FinderGetting busy with the Ubercode.

I've updated the module so that the patch to uc_cart is no longer required. (Thanks for the suggestion Ryan!)

Also, this module now has a contribution page at:
http://www.ubercart.org/contrib/1403

AttachmentSize
uc_wishlist-0.2.tar.gz14.6 KB
Posts: 4256
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Off topic... the Sundays Energy equation grows larger and larger... I think next it should be broken down like so:

Sundays Energy = Drupal * Design + Drupal * Development + Drupal * Hosting + Ubercart * Design + Ubercart * Development + Ubercart * Hosting

But that wouldn't be quite so pretty. ^_^

Posts: 1998
Joined: 08/07/2007
AdministratoreLiTe!

Someone needs to discover the Übercart Quadratic Equation.

Yes, I'm a nerd.

Posts: 29
Joined: 08/09/2007
Bug FinderEarly adopter... addicted to alphas.

We're on that discovery mission. Is there a Pi badge in the works for the ultimate equation?
Anyways, we're meeting with the client who will be using the registry next week with hopes of getting the site live within two weeks. Please keep us updated with any tests and/or suggestions.

--

Drupal + Ubercart = Sundays Energy
_____________________

Analog Hero - Vintage Gadgets

Posts: 5
Joined: 12/20/2007

detour, cool mod!

How would I go about modifying this into something that is e-mail based -- example: Billy wants a new pair of shoes and socks (yes, BIlly is a special boy). So, Billy adds these items to his cart, and fires off the Wish List link through an embedded form (with comment box) to his internet-illiterate Uncle, so that Uncle Tom can buy these products by clicking on the link in his e-mail.

Could that work?

Posts: 46
Joined: 10/02/2007
Bug FinderGetting busy with the Ubercode.

CLiDE, I think you've described an important feature addition for the wish list module: customers should be able to send a link to their wish list through the store site.

I'll get this slated for one of the next updates, unless of course you want to dig around in the code and post a patch.

Posts: 5
Joined: 12/20/2007

Yeah, I think I was drunk when I wrote that message ... it clearly said it in your original post, lol.

Posts: 27
Joined: 01/17/2008

detour -- the wishlist module makes the Search Settings not work -- I've narrowed this error down to the Wish List Module:

Fatal error: Cannot use string offset as an array in /home/.zhukov/killerjerseys/killerjerseys.com/includes/form.inc on line 680

This error message has been driving me nuts all week! I trashed my drupal install because of it, lol. All is good, though Laughing out loud

Also, the "Hide block if wish list is empty." option in the Block settings doesn't work.

I'm using version 0.4.

Otherwise, great work!

Posts: 46
Joined: 10/02/2007
Bug FinderGetting busy with the Ubercode.

KillerJerseys,

Thanks for reporting these problems. I've fixed both (and made other improvements) in the latest release, version 0.5. Download it from the contrib page:

http://www.ubercart.org/contrib/1403

Posts: 23
Joined: 03/13/2008

Joe, Is there a way that users can add products to the wish list that are not in the catalog. I think that would be helpful because in my case it becomes hard for the store to carry all variety of products..

thank you,

PS: Ubercart team great job.

Posts: 23
Joined: 03/13/2008

detour,

could you tell me how would i go about if i want to send automatically email notifications to users when something in their wishlist is purchased.

thanks

Posts: 1
Joined: 05/26/2008

Couple of issues (somewhat related):

1) I have added the wishlist module to our ubercart installation, it seems to work fine, except for one thing. Our store is 100% digital distribution - ie addresses are not required at all for purchasing items. Is there an easy way to disable the 'address requirement' that the wishlist seems to impose on users creating wishlists?

2) A secondary issue regarding wishlists, I have two countries enabled, canada and US - but when I try to select the Canada address and the a province, the wishlist 'submit' prompt tells me that I have selected an invalid entry and to contact the site administrator. The 'zone' listbox then reverts to US states, even though the country list selection remains on canada.

If I choose US and a state for my mailing address, it submits fine.

If I can figure out #1 (disabling the address requirement), then #2 is a non-issue, but I'm sure will arise for other users that DO care about having non-US addresses available in their stores.

Thanx in advance,