I have crawled the forums and only find discussion around issuing a coupon code at registration, not a UNIQUE coupon code.

The requirement is to pull unique coupon codes at user registration from the Ubercart-generated bulk coupon codes. Rather than pull from an additional table, I'm hoping there is a solution out there that leverages an existing module.

The site is running 6.x and Ubercart is able to generate the bulk codes via uc_coupon, no problem. I want to assign a unique code at registration of a new user and email that code to the new user.

Any direction is greatly appreciated.

Comments

lanexa’s picture

Not sure why this post didn't gain any traction, but I thought I would take a moment to post my solution in case anyone else has this issue.

The bulk codes generated from Ubercart were dumped into a new MySQL table, and a simple PHP function was developed to pull a new code at the time of Drupal registration. The user id was passed into this function to ensure that a unique code was assigned to the correct user, and to make sure that no code was used twice.

In order to know who the user is that registered, here is my code snip:

// need to set the $user to global to get variables
global $user;

// load the user profile and get first and last name, then concatenate
profile_load_profile($user);
$fname = $user->{profile_fname};
$lname = $user->{profile_lname};
$fullname = $fname . " " . $lname;

I will post the function here if anyone is interested. Just let me know.
Chris

jayemel’s picture

I would like to see your solution Lanexa, I too need to do this same thing. Thanks!