Successfully Track OSCommerce Tracking Results

I set the tracking code on the checkout_success.php page. I need to be able to copy the coupon code / discount code from the order if it was used so that I can repeat it in my tracking script.

I was wondering if anyone knows how to do this?

I use this contribution of discount coupons; ot_discount_coupons.php, August 4, 2006, author: Kristen G. Thorson, ot_discount_coupon_codes version 3.0

It seems that the coupon code is not actually stored in order_totals, but in a separate table discount_coupons_to_orders. Is there a request that I can make in this table to find the appropriate coupon code used for this order? I tried the following, but returned nothing;

$coupon_query = tep_db_query("select coupons_id from discount_coupons_to_orders where orders_id = '".(int)$orders['orders_id']."' ORDER BY orders_id DESC LIMIT 1"); $coupon_id = tep_db_fetch_array($coupon_query); $couponid = $coupon_id['coupon_id'];

Thank.

+3
source share
3 answers

Instead:

$couponid = $coupon_id['coupon_id'];

Try:

$couponid = $coupon_id['coupons_id'];
+3
source

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.

+1
source

If I remember correctly, you can transfer the coupon code through the page and access it. If not, hack the coupon entry page, and save the part in the session variable if the coupon is in order. On the success page, you simply use something like $ _SESSION ['couponcode'], without using additional queries. This is probably 2 lines of modification on the coupon entry page.

0
source

Source: https://habr.com/ru/post/1738005/


All Articles