If this is your first visit, check our documentation. To post, register or login.
Forums / Contribution-Writing Guidelines / Adding a field to the orders table and then need to recall it with checkout_success

Adding a field to the orders table and then need to recall it with checkout_success

Locked

Started by retched on 12 Aug 2010, 4:11 AM · Views: 2,104

Results 1 to 1 of 1
This thread is locked. New replies are disabled.
12 Aug 2010, 4:11 AM
#1
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
949
Plugin Contributions:
3

Adding a field to the orders table and then need to recall it with checkout_success

Here's one that I'm needing help with.

I'm using a survey program to ask my questions what they thought about their experience with my store. An entirely separate program will be doing this. That survey program allows for "tokens" to be created for each surveyor (in this case the customers) and let them take it.

What I want to do is:

  1. After checkout is successful, create a token using a random character generator (I've already made it and will provide for the heck of it at the bottom of this post.) and insert that token into the orders database. (In addition, I have to insert it into the survey program database but since both are being run from the same database (different tables), I'll use the $db->Execute command.) Assuming the name survey_token as its column name in Zen's Orders DB.

  2. On the template (or define) page for checkout_success, I want to link that customer to that survey. Essentially I would need to call the value I made from step one. (Essentially how checkout_success calls for the order id of the order just created.)

Here is the function I'm using to generate the token for the customer:

    function random_gen($length)
    {
      $random= "";

      $char_list = "AzByCxDwEvFuGtHsIrJqKpLoMnNmOlPkQjRiShTgUfVeWdXcYbZa";
      $char_list .= "10293847566574839201";
      // Add the special characters to $char_list if needed

      for($i = 0; $i < $length; $i++)
      {
        srand((double)microtime()*1000000);
        $random .= substr($char_list,rand(1,(strlen($char_list))), 1);
      }
      return $random;
    }
```Anyone know where I should start making edits?