My solution is probably a little more than what you were looking for, but worked well for my work. I am making a request at line 76 in this php file, which requests order information and a coupon code.
$orders_query = tep_db_query("select orders.orders_id from " . TABLE_ORDERS . " left join discount_coupons_to_orders dco on orders.orders_id=dco.orders_id where customers_id = '" . (int)$customer_id . "' order by date_purchased desc limit 1");
$orders = tep_db_fetch_array($orders_query);
The purpose of this is so that the customer can get information about their order. You can refer to your coupon code here, as I showed that the discount was applied.
echo '<br /><br /><span style="color:red"><b>Your order number is #'.$orders['orders_id'].(!empty($orders['coupons_id']) ? ' Discount Code: '.$orders['coupons_id'] : "").' you can now <a href="account_history_info.php?order_id='.$orders['orders_id'].'" style="text-decoration: underline;color:red">view your receipt</a></b>.</span>';
We found that customers immediately want to see the "receipt", so we will directly contact the account history. But the key point here is that if you use the connection with the main order information, you can access the order information and coupon code in one shot.
source
share