Closed (fixed)
Project:
UC Gift Certificate
Version:
5.x-1.1-beta3
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
4 Sep 2009 at 20:46 UTC
Updated:
29 Dec 2010 at 18:00 UTC
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
Comment #1
ycimlynn commentedLooks like this was taken care of in the new dev version! Just tested the dev version and looks great!
Comment #2
jrust commented