Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
$result = db_query("SELECT nid, qty, data FROM {uc_order_products} WHERE order_id = %d", $order_id);
to
$result = db_query("SELECT uc.nid, uc.qty, uc.data FROM {uc_order_products} as uc INNER JOIN {node} as n ON uc.nid = n.nid WHERE uc.order_id = %d AND n.status=1", $order_id);
This will make sure the node is published when attempting a reorder.
Also, if you wanted to tell the user that deleted/unpublished items are no longer available do the following:
Replace the query again with $result = db_query("SELECT uc.nid, uc.qty, uc.data, uc.title, n.status FROM {uc_order_products} as uc LEFT JOIN {node} as n ON uc.nid = n.nid WHERE uc.order_id = %d", $order_id);
This will add the order item title and the node status to the object (status will be 1 for published, 0 for unpublished or NULL for deleted)
Now inside the while loop put all the current code inside the following condition:
if ($product->status == '1') {
// current code
} else {
drupal_set_message($product->title." is no longer available", 'error');
}
This will add any deleted/unpublished order items to an error message to be displayed after the redirect.
Comments
Comment #1
calbasiI think so...
Comment #2
maverick619 commentedOn line 82 change:
$result = db_query("SELECT nid, qty, data FROM {uc_order_products} WHERE order_id = %d", $order_id);to
$result = db_query("SELECT uc.nid, uc.qty, uc.data FROM {uc_order_products} as uc INNER JOIN {node} as n ON uc.nid = n.nid WHERE uc.order_id = %d AND n.status=1", $order_id);This will make sure the node is published when attempting a reorder.
Comment #3
maverick619 commentedAlso, if you wanted to tell the user that deleted/unpublished items are no longer available do the following:
Replace the query again with
$result = db_query("SELECT uc.nid, uc.qty, uc.data, uc.title, n.status FROM {uc_order_products} as uc LEFT JOIN {node} as n ON uc.nid = n.nid WHERE uc.order_id = %d", $order_id);This will add the order item title and the node status to the object (status will be 1 for published, 0 for unpublished or NULL for deleted)
Now inside the while loop put all the current code inside the following condition:
This will add any deleted/unpublished order items to an error message to be displayed after the redirect.
Comment #4
tr commentedThanks. I will be making these changes in the next few days.
Comment #5
calbasiHello,
Is the maverick619 code added to the dev version yet?
Regards