In this function:

function uc_gift_certificate_create_new_certs($order_id) {

some of the information does not save to the database.

To make this work, I had to apply these changes. I would do a patch, but never done one before, so not sure the correct protocol to do it.

  global $user;
  
  $order = db_query("SELECT * FROM {uc_order_products} WHERE order_id = %d", $order_id);
+  $order2 = db_query("SELECT uid FROM {uc_orders} WHERE order_id = %d", $order_id);  // FIX added this line
+  $order2Certs = db_fetch_object($order2);  // FIX added this line

  while ($orderCerts = db_fetch_object($order)) {
    if ($orderCerts->data){
      $data = array();
      $data = unserialize($orderCerts->data);
	
      // Check if the product is a gift certificate
      if ($data && $data['attributes'] && isset($data['attributes']["Certificate Amount"])){

        $data['attributes']['Certificate Code'] = '';

        // Generate a random code and insert the certificate. First delete other certificates for this order_id
-        if (db_query("INSERT INTO {uc_gift_certificates} (name, value, purchaser_id, order_id, order_product_id) VALUES (
         '%s','%s', %d, %d, %d)", "Gift Certificate",  $orderCerts->qty * $orderCerts->price, $order->uid, $order->order_id,
         $orderCerts->order_product_id)) {
+	  if (db_query("INSERT INTO {uc_gift_certificates} (name, value, purchaser_id, order_id, order_product_id) 
          VALUES ('%s', '%s', %d, %d, %d)", "Gift Certificate",  $orderCerts->qty * $orderCerts->price, $order2Certs->uid, 
          $order_id, $orderCerts->order_product_id)) {

          $certificate_id = mysql_insert_id();
          $cert_code = $certificate_id ."-". uc_gift_certificate_mKey();
          db_query("UPDATE {uc_gift_certificates} SET cert_code = '%s' WHERE certificate_id = %d", $cert_code, $certificate_id);

Comments

ycimlynn’s picture

Looks like this was taken care of in the new dev version! Just tested the dev version and looks great!

jrust’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.