Zen Cart Logo
Forums / Managing Customers and Orders / Trying to add coupon code to packing slip

Trying to add coupon code to packing slip

Locked

Views: 2,181

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
9 Apr 2007, 7:35 PM
#1
lukemcr avatar

lukemcr

New Zenner

Join Date:
Feb 2007
Location:
Sacramento, CA
Posts:
64
Plugin Contributions:
0

Trying to add coupon code to packing slip

I'm trying to add the coupon code that the customer used to the packing slip of the order they create.

The SQL code I'm using is

SELECT coupon_code FROM zen_coupons,zen_coupon_redeem_track WHERE zen_coupons.coupon_id = zen_coupon_redeem_track.coupon_id AND zen_coupon_redeem_track.order_id =whatevertheordernumberis;

Translated into ZenCart PHP, it turns into

<?php $order_coupon_slip = $db->Execute("SELECT coupon_code FROM " . TABLE_COUPONS . "," . TABLE_COUPON_REDEEM_TRACK . " WHERE " . TABLE_COUPONS . ".coupon_id = " . TABLE_COUPON_REDEEM_TRACK . ".coupon_id AND " . TABLE_COUPON_REDEEM_TRACK . ".order_id = '" . (int)$oID . "'"); ?>

inserted into super_packingslip.php. (Me using Super Orders shouldn't matter.)

I'm attempting to call $order_coupon_slip within super_packingslip.php using either *

<?php echo $order_coupon_slip->customer['coupon_code']; ?>*

or

<?php echo $order_coupon_slip; ?>

I'm pretty sure I have the SQL query correct: however, what would be the best way to call the function? Currently just calling the variable results in "Object" appearing on the output page, while calling the longer function doesn't display anything. The ZenCart Developer's Wiki didn't help much, unfortunately.

I'm using Zen Cart 1.3.7 with Apache 1.3, MySQL 3.23, PHP 4.4.6 and Slackware 10.

Thanks for your help.

9 Apr 2007, 7:40 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Trying to add coupon code to packing slip

Perhaps pulling the coupon_code field from the orders table might be easier? :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

9 Apr 2007, 8:02 PM
#3
lukemcr avatar

lukemcr

New Zenner

Join Date:
Feb 2007
Location:
Sacramento, CA
Posts:
64
Plugin Contributions:
0

Re: Trying to add coupon code to packing slip

Hm...

yeah, calling zen_orders.coupon_code is simpler. :-) I guess when there's 57 columns in a table, it's easy to miss an important one.

I'm still getting the same result though: when I call the variable I have the SQL query stored as, I'm getting "Object" displaying on the page where the coupon code should be.

My new code (thanks Ajeh!):

*<?php $order_coupon_slip = $db->Execute("SELECT coupon_code FROM " . TABLE_ORDERS . " WHERE orders_id = '" . (int)$oID . "'"); ?>

*and it's called by

<?php echo $order_coupon_slip; ?>

Any ideas?

10 Apr 2007, 12:32 AM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Trying to add coupon code to packing slip

Try to call it with:

$order_coupon_slip->fields['coupon_code']

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

10 Apr 2007, 4:05 PM
#5
lukemcr avatar

lukemcr

New Zenner

Join Date:
Feb 2007
Location:
Sacramento, CA
Posts:
64
Plugin Contributions:
0

Re: Trying to add coupon code to packing slip

Thanks for the help, Ajeh.

Unfortunately, however,

<?php echo $order_coupon_slip->fields['coupon_code']; ?> isn't working. "Object" isn't being returned: there's just nothing appearing.

10 Apr 2007, 5:57 PM
#6
lukemcr avatar

lukemcr

New Zenner

Join Date:
Feb 2007
Location:
Sacramento, CA
Posts:
64
Plugin Contributions:
0

Re: Trying to add coupon code to packing slip

Alright, I figured it out: there just wasn't a coupon code associated with the particular orders I was looking at. When I viewed the packing slip of an order that I knew had a coupon code with it, it worked fine.

Thanks Ajeh. :-)

To everyone else: this thread

http://www.zen-cart.com/forum/showthread.php?t=37905&page=1

Deals with basically the same thing, and it helped me some too.