If this is your first visit, check our documentation. To post, register or login.
Forums / Customization from the Admin / Show referral on Invoice?

Show referral on Invoice?

Locked

Started by blarney on 12 May 2006, 8:26 PM · Views: 5,658

Results 1 to 10 of 10
This thread is locked. New replies are disabled.
12 May 2006, 8:26 PM
#1
blarney avatar

blarney

New Zenner

Join Date:
Oct 2005
Location:
Connectiuct
Posts:
69
Plugin Contributions:
1

Show referral on Invoice?

I think I almost have it but need a bit of help. My client wants the referral ID showing on the invoice page. I've been taking stabs at it with limited success. In the admin/invoice.php file, I added a row below the payment method as follows:

<tr> <td class="main"><b>Key Code #:</b></td> <td class="main"><?php echo $order->customer['coupon_code']; ?></td> </tr>

The referral code did not show up but the "Key Code" label did. I tried adding the "coupon_code" to the $db->Execute above that to see if that helped but still no luck. Since I'm running out of guesses, I need help from someone who knows what they are doing <grin>.

How can I display the referral code?

Thanks,

Jim Smith

PS, BTW, nice new look to the Zen-cart.com web site!

12 May 2006, 10:05 PM
#2
ajeh avatar

ajeh

Oba-san

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

Re: Show referral on Invoice?

Find the select statement in the /admin/invoice.php

      $order_check = $db->Execute("select cc_cvv, customers_name, customers_company, customers_street_address,
                                    customers_suburb, customers_city, customers_postcode,
                                    customers_state, customers_country, customers_telephone,
                                    customers_email_address, customers_address_format_id, delivery_name,
                                    delivery_company, delivery_street_address, delivery_suburb,
                                    delivery_city, delivery_postcode, delivery_state, delivery_country,
                                    delivery_address_format_id, billing_name, billing_company,
                                    billing_street_address, billing_suburb, billing_city, billing_postcode,
                                    billing_state, billing_country, billing_address_format_id,
                                    payment_method, cc_type, cc_owner, cc_number, cc_expires, currency,
                                    currency_value, date_purchased, orders_status, last_modified
                             from " . TABLE_ORDERS . "
                             where orders_id = '" . (int)$oID . "'");

coupon_code is not in there ... you need to add the field then you can call the Coupon Code used for that order with:

$order_check->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!

13 May 2006, 2:19 AM
#3
blarney avatar

blarney

New Zenner

Join Date:
Oct 2005
Location:
Connectiuct
Posts:
69
Plugin Contributions:
1

Re: Show referral on Invoice?

Ajeh,
That took care of it. The same thing worked for adding the referral code to the packing slip if anyone is looking for that as well. Thanks!

Regards,

Jim Smith

13 May 2006, 3:04 AM
#4
blarney avatar

blarney

New Zenner

Join Date:
Oct 2005
Location:
Connectiuct
Posts:
69
Plugin Contributions:
1

Re: Show referral on Invoice?

Oops! I spoke too soon. What I wanted to show up on the invoice is the referral code, not the coupon code. I unsuccessfully tried a few variations like this:

<?php echo $order_check->fields['customers_referral']; Can you please tell me what I should be using and whether to include it in the $db->Execute list or not. Thanks. Jim Smith
13 May 2006, 3:50 AM
#5
ajeh avatar

ajeh

Oba-san

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

Re: Show referral on Invoice?

While you could get the customer's referal code ... would this really have a desired effect as once the referral code is assigned to a customer it remains always the same ...

It would be easier to make a function to look-up the customers_referral from the customers table based on the orders customers_id ...

Then, you could just echo the function on the invoice.php ...

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!

13 May 2006, 1:18 PM
#6
blarney avatar

blarney

New Zenner

Join Date:
Oct 2005
Location:
Connectiuct
Posts:
69
Plugin Contributions:
1

Re: Show referral on Invoice?

Ajeh:

While you could get the customer's referal code ... would this really have a desired effect as once the referral code is assigned to a customer it remains always the same ...

Yes it seems odd on the surface but this client prints each invoice as his record for sales. The referral code tells him which organization gets credit for that order. His staffers look at each day's invoices and generate a manual report based upon that. The Reports/Customer Referral report will be helpful for him to reconcile these reports but he still wants it to appear on each invoice as well.

Ajeh:

It would be easier to make a function to look-up the customers_referral from the customers table based on the orders customers_id ...

Then, you could just echo the function on the invoice.php ...

That's what I need some help with. I've tried to guess at it but coming up empty. Can I get some help putting that together?

Thanks,

Jim Smith

13 May 2006, 2:00 PM
#7
blarney avatar

blarney

New Zenner

Join Date:
Oct 2005
Location:
Connectiuct
Posts:
69
Plugin Contributions:
1

Re: Show referral on Invoice?

Ajeh:

It would be easier to make a function to look-up the customers_referral from the customers table based on the orders customers_id ...

Then, you could just echo the function on the invoice.php ...

Here's the closest unsuccessful guess I've hobbled together so far if that makes it easier:

<?php // look-up customer referral code from customers table function zen_get_customers_referral ($lookup) { global $db; if ($lookup==0) { return 'Unspecified'; } $check_options = $db->Execute("select customers_referral from " . TABLE_CUSTOMERS . " where customers_referral_code='" . $lookup . "'"); return $order_check->fields['customers_referral_code']; } ?>

===================

Thanks. js

13 May 2006, 2:03 PM
#8
ajeh avatar

ajeh

Oba-san

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

Re: Show referral on Invoice?

Add a function to a new file and put it in the /admin/includes/functions/extra_functions

  function zen_get_orders_customers_referral($orders_id) {
    global $db;
    $sql = "SELECT customers_id from " . TABLE_ORDERS . " where orders_id='" . $orders_id . "'";
    $check_orders = $db->Execute($sql);
    $check_customers_id = $check_orders->fields['customers_id'];
    $sql = "SELECT customers_referral from " . TABLE_CUSTOMERS . " where customers_id='" . $check_customers_id . "'";
    $check_customers_referral = $db->Execute($sql);
    return $check_customers_referral->fields['customers_referral'];
  }

Then to see the results in /admin/invoice.php stick this inside a php area:

echo 'I SEE ' . zen_get_orders_customers_referral((int)$oID) . '<br>';

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!

13 May 2006, 2:22 PM
#9
blarney avatar

blarney

New Zenner

Join Date:
Oct 2005
Location:
Connectiuct
Posts:
69
Plugin Contributions:
1

Re: Show referral on Invoice?

Ajeh,
That took care of it. Thanks!

Jim Smith

13 May 2006, 7:53 PM
#10
ajeh avatar

ajeh

Oba-san

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

Re: Show referral on Invoice?

Glad that the new code could work for you ... thanks for the update ... :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!