Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / changing the invoice?

changing the invoice?

Locked

Views: 2,503

Results 1 to 14 of 14
This thread is locked. New replies are disabled.
2 Jul 2008, 1:39 PM
#1
machaneko avatar

machaneko

Zen Follower

Join Date:
Apr 2008
Posts:
174
Plugin Contributions:
0

changing the invoice?

i want to change the way the invoice prints up.

i want the quantity to be bigger and red, and add the manufacturer in the description. i'm pretty sure i should change up the invoice.php file but i don't know what to add or delete to make changes. can anyone help please?

2 Jul 2008, 7:20 PM
#2
sanguisdesign avatar

sanguisdesign

Inactive

Join Date:
May 2005
Location:
Western MA, USA
Posts:
588
Plugin Contributions:
1

Re: changing the invoice?

the best way to learn how to do this is to play around w/ the file. I sugest keeping a back up and going nuts.

2 Jul 2008, 7:21 PM
#3
machaneko avatar

machaneko

Zen Follower

Join Date:
Apr 2008
Posts:
174
Plugin Contributions:
0

Re: changing the invoice?

sanguisdesign:

the best way to learn how to do this is to play around w/ the file. I sugest keeping a back up and going nuts.

that is not an option for me since the site is live and takes orders.

3 Jul 2008, 12:35 PM
#4
machaneko avatar

machaneko

Zen Follower

Join Date:
Apr 2008
Posts:
174
Plugin Contributions:
0

Re: changing the invoice?

i added this code but it doesnt show the manufacturer.

anyone know why?

$order->products[$i]['manufacturer']

3 Jul 2008, 1:14 PM
#5
sanguisdesign avatar

sanguisdesign

Inactive

Join Date:
May 2005
Location:
Western MA, USA
Posts:
588
Plugin Contributions:
1

Re: changing the invoice?

MachaNeko:

i added this code but it doesnt show the manufacturer.

anyone know why?

$order->products[$i]['manufacturer']

I dont believe that the product manufacturer is saved in the orders database tables and there fore would not be in the array. you will prob have to write another SQL query to get that. it will prob be (this is me not looking up the SQL structure so it may be off in the names) like:

SELECT manufacturers_name FROM manufacturers(M) WHERE products.products_id =  '. $order->products[$i][products_id] . '  AND M.id = products.manufacture_id

This is are really good opportunity to learn about Zen Cart's brilliant query factory.

3 Jul 2008, 1:15 PM
#6
machaneko avatar

machaneko

Zen Follower

Join Date:
Apr 2008
Posts:
174
Plugin Contributions:
0

Re: changing the invoice?

i was afraid of that. ill try the code and try not to kill anything.

3 Jul 2008, 1:18 PM
#7
sanguisdesign avatar

sanguisdesign

Inactive

Join Date:
May 2005
Location:
Western MA, USA
Posts:
588
Plugin Contributions:
1

Re: changing the invoice?

Another set if tips is never work on a live site.
I keep a development version of every site I work with in a separate location on the server and tie them to gather with Subversion. that way I dont have to do my work twice but never have to think about crippling a live site up.

3 Jul 2008, 1:20 PM
#8
machaneko avatar

machaneko

Zen Follower

Join Date:
Apr 2008
Posts:
174
Plugin Contributions:
0

Re: changing the invoice?

my boss makes me use the live site. they have no alternate server or location for me to test this. he thinks backups are good enough.

3 Jul 2008, 2:55 PM
#9
machaneko avatar

machaneko

Zen Follower

Join Date:
Apr 2008
Posts:
174
Plugin Contributions:
0

Re: changing the invoice?

i entered in code my boss had to give me. turns out the info i need isnt in the table and has to be pulled from another one.

i get this error:
Fatal error: Cannot use object of type queryFactoryResult as array in C:\xampp\htdocs\forcemeasurement\admin\includes\classes\order.php on line 129

this is the code given:
$products_manufacturers = $db->Execute("Select manufacturers_name from manufacturers inner join Products on products.manufacturers_id = manufacturers_id WHERE products.products_id = " + $orders_products['products_id'] );

this is the whole file with the code:

<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce                                       |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003 The zen-cart developers                           |
// |                                                                      |
// | http://www.zen-cart.com/index.php                                    |
// |                                                                      |
// | Portions Copyright (c) 2003 osCommerce                               |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license,       |
// | that is bundled with this package in the file LICENSE, and is        |
// | available through the world-wide-web at the following url:           |
// | http://www.zen-cart.com/license/2_0.txt.                             |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to       |
// | [email protected] so we can mail you a copy immediately.          |
// +----------------------------------------------------------------------+
//  $Id: order.php 4774 2006-10-17 06:47:16Z drbyte $
//

  class order {
    var $info, $totals, $products, $customer, $delivery, $products_manufacturers;

    function order($order_id) {
      $this->info = array();
      $this->totals = array();
      $this->products = array();
      $this->customer = array();
      $this->delivery = array();

      $this->query($order_id);
    }

    function query($order_id) {
      global $db;
      $order = $db->Execute("select cc_cvv, customers_name, customers_company, customers_street_address,
                                    customers_suburb, customers_city, customers_postcode, customers_id,
                                    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,
                                    coupon_code, payment_method, payment_module_code, shipping_method,
                                    shipping_module_code,
                                    cc_type, cc_owner, cc_number, cc_expires, currency,
                                    currency_value, date_purchased, orders_status, last_modified,
                                    order_total, order_tax, ip_address
                             from " . TABLE_ORDERS . "
                             where orders_id = '" . (int)$order_id . "'");


      $totals = $db->Execute("select title, text, class
                              from " . TABLE_ORDERS_TOTAL . "
                              where orders_id = '" . (int)$order_id . "'
                              order by sort_order");

      while (!$totals->EOF) {
        $this->totals[] = array('title' => $totals->fields['title'],
                                'text' => $totals->fields['text'],
                                'class' => $totals->fields['class']);
        $totals->MoveNext();
      }

      $this->info = array('currency' => $order->fields['currency'],
                          'currency_value' => $order->fields['currency_value'],
                          'payment_method' => $order->fields['payment_method'],
                          'payment_module_code' => $order->fields['payment_module_code'],
                          'shipping_method' => $order->fields['shipping_method'],
                          'shipping_module_code' => $order->fields['shipping_module_code'],
                          'coupon_code' => $order->fields['coupon_code'],
                          'cc_type' => $order->fields['cc_type'],
                          'cc_owner' => $order->fields['cc_owner'],
                          'cc_number' => $order->fields['cc_number'],
                          'cc_cvv' => $order->fields['cc_cvv'],
                          'cc_expires' => $order->fields['cc_expires'],
                          'date_purchased' => $order->fields['date_purchased'],
                          'orders_status' => $order->fields['orders_status'],
                          'total' => $order->fields['order_total'],
                          'tax' => $order->fields['order_tax'],
                          'last_modified' => $order->fields['last_modified'],
                          'ip_address' => $order->fields['ip_address']
                          );

      $this->customer = array('name' => $order->fields['customers_name'],
                              'id' => $order->fields['customers_id'],
                              'company' => $order->fields['customers_company'],
                              'street_address' => $order->fields['customers_street_address'],
                              'suburb' => $order->fields['customers_suburb'],
                              'city' => $order->fields['customers_city'],
                              'postcode' => $order->fields['customers_postcode'],
                              'state' => $order->fields['customers_state'],
                              'country' => $order->fields['customers_country'],
                              'format_id' => $order->fields['customers_address_format_id'],
                              'telephone' => $order->fields['customers_telephone'],
                              'email_address' => $order->fields['customers_email_address']);

      $this->delivery = array('name' => $order->fields['delivery_name'],
                              'company' => $order->fields['delivery_company'],
                              'street_address' => $order->fields['delivery_street_address'],
                              'suburb' => $order->fields['delivery_suburb'],
                              'city' => $order->fields['delivery_city'],
                              'postcode' => $order->fields['delivery_postcode'],
                              'state' => $order->fields['delivery_state'],
                              'country' => $order->fields['delivery_country'],
                              'format_id' => $order->fields['delivery_address_format_id']);

      $this->billing = array('name' => $order->fields['billing_name'],
                             'company' => $order->fields['billing_company'],
                             'street_address' => $order->fields['billing_street_address'],
                             'suburb' => $order->fields['billing_suburb'],
                             'city' => $order->fields['billing_city'],
                             'postcode' => $order->fields['billing_postcode'],
                             'state' => $order->fields['billing_state'],
                             'country' => $order->fields['billing_country'],
                             'format_id' => $order->fields['billing_address_format_id']);

      $index = 0;
      $orders_products = $db->Execute("select orders_products_id, products_id, products_name, products_model,
                                              products_price, products_tax, products_quantity,
                                              final_price, onetime_charges,
                                              product_is_free
                                       from " . TABLE_ORDERS_PRODUCTS . "
                                       where orders_id = '" . (int)$order_id . "'");

	  $products_manufacturers = $db->Execute("Select manufacturers_name from manufacturers inner join Products on products.manufacturers_id = manufacturers_id WHERE products.products_id = " + $orders_products['products_id'] );


      while (!$orders_products->EOF) {
// convert quantity to proper decimals - account history
          if (QUANTITY_DECIMALS != 0) {
            $fix_qty = $orders_products->fields['products_quantity'];
            switch (true) {
            case (!strstr($fix_qty, '.')):
              $new_qty = $fix_qty;
              break;
            default:
              $new_qty = preg_replace('/[0]+$/', '', $orders_products->fields['products_quantity']);
              break;
            }
          } else {
            $new_qty = $orders_products->fields['products_quantity'];
          }

          $new_qty = round($new_qty, QUANTITY_DECIMALS);

          if ($new_qty == (int)$new_qty) {
            $new_qty = (int)$new_qty;
          }

        $this->products[$index] = array('manufacturers' => $products_manufacturers->fields['products_manufacturers'],
        								'qty' => $new_qty,
        		                        'id' => $orders_products->fields['products_id'],
                                        'name' => $orders_products->fields['products_name'],
                                        'model' => $orders_products->fields['products_model'],
                                        'tax' => $orders_products->fields['products_tax'],
                                        'price' => $orders_products->fields['products_price'],
                                        'onetime_charges' => $orders_products->fields['onetime_charges'],
                                        'final_price' => $orders_products->fields['final_price'],
                                        'product_is_free' => $orders_products->fields['product_is_free']);

        $subindex = 0;
        $attributes = $db->Execute("select products_options, products_options_values, options_values_price,
                                           price_prefix,
                                           product_attribute_is_free
                                    from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . "
                                    where orders_id = '" . (int)$order_id . "'
                                    and orders_products_id = '" . (int)$orders_products->
                                    fields['orders_products_id'] . "'");
        if ($attributes->RecordCount()>0) {
          while (!$attributes->EOF) {
            $this->products[$index]['attributes'][$subindex] = array('option' => $attributes->
            fields['products_options'],
                                                                     'value' => $attributes->
                                                                     fields['products_options_values'],
                                                                     'prefix' => $attributes->
                                                                     fields['price_prefix'],
                                                                     'price' => $attributes->
                                                                     fields['options_values_price'],
                                                                     'product_attribute_is_free' =>
                                                                     $attributes->
                                                                     fields['product_attribute_is_free']);

            $subindex++;
            $attributes->MoveNext();
          }
        }
        $index++;
        $orders_products->MoveNext();
      }
    }
  }
?>

can anyone help me figure out why its not working?

3 Jul 2008, 5:15 PM
#10
machaneko avatar

machaneko

Zen Follower

Join Date:
Apr 2008
Posts:
174
Plugin Contributions:
0

Re: changing the invoice?

i got new code that gives me a new error lol

new code line:
$products_manufacturers = $db->Execute("select manufacturers_name from " . TABLE_manufacturers INNER JOIN TABLE_Products . " on products.manufacturers_id = manufacturers_id WHERE products.products_id = '" . + $orders_products['products_id'] . "'" );

Sorry i posted the wrong error on here.
new error:
Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\forcemeasurement\admin\includes\classes\order.php on line 129

the order.php code

<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce                                       |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003 The zen-cart developers                           |
// |                                                                      |
// | http://www.zen-cart.com/index.php                                    |
// |                                                                      |
// | Portions Copyright (c) 2003 osCommerce                               |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license,       |
// | that is bundled with this package in the file LICENSE, and is        |
// | available through the world-wide-web at the following url:           |
// | http://www.zen-cart.com/license/2_0.txt.                             |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to       |
// | [email protected] so we can mail you a copy immediately.          |
// +----------------------------------------------------------------------+
//  $Id: order.php 4774 2006-10-17 06:47:16Z drbyte $
//

  class order {
    var $info, $totals, $products, $customer, $delivery, $products_manufacturers;

    function order($order_id) {
      $this->info = array();
      $this->totals = array();
      $this->products = array();
      $this->customer = array();
      $this->delivery = array();

      $this->query($order_id);
    }

    function query($order_id) {
      global $db;
      $order = $db->Execute("select cc_cvv, customers_name, customers_company, customers_street_address,
                                    customers_suburb, customers_city, customers_postcode, customers_id,
                                    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,
                                    coupon_code, payment_method, payment_module_code, shipping_method,
                                    shipping_module_code,
                                    cc_type, cc_owner, cc_number, cc_expires, currency,
                                    currency_value, date_purchased, orders_status, last_modified,
                                    order_total, order_tax, ip_address
                             from " . TABLE_ORDERS . "
                             where orders_id = '" . (int)$order_id . "'");


      $totals = $db->Execute("select title, text, class
                              from " . TABLE_ORDERS_TOTAL . "
                              where orders_id = '" . (int)$order_id . "'
                              order by sort_order");

      while (!$totals->EOF) {
        $this->totals[] = array('title' => $totals->fields['title'],
                                'text' => $totals->fields['text'],
                                'class' => $totals->fields['class']);
        $totals->MoveNext();
      }

      $this->info = array('currency' => $order->fields['currency'],
                          'currency_value' => $order->fields['currency_value'],
                          'payment_method' => $order->fields['payment_method'],
                          'payment_module_code' => $order->fields['payment_module_code'],
                          'shipping_method' => $order->fields['shipping_method'],
                          'shipping_module_code' => $order->fields['shipping_module_code'],
                          'coupon_code' => $order->fields['coupon_code'],
                          'cc_type' => $order->fields['cc_type'],
                          'cc_owner' => $order->fields['cc_owner'],
                          'cc_number' => $order->fields['cc_number'],
                          'cc_cvv' => $order->fields['cc_cvv'],
                          'cc_expires' => $order->fields['cc_expires'],
                          'date_purchased' => $order->fields['date_purchased'],
                          'orders_status' => $order->fields['orders_status'],
                          'total' => $order->fields['order_total'],
                          'tax' => $order->fields['order_tax'],
                          'last_modified' => $order->fields['last_modified'],
                          'ip_address' => $order->fields['ip_address']
                          );

      $this->customer = array('name' => $order->fields['customers_name'],
                              'id' => $order->fields['customers_id'],
                              'company' => $order->fields['customers_company'],
                              'street_address' => $order->fields['customers_street_address'],
                              'suburb' => $order->fields['customers_suburb'],
                              'city' => $order->fields['customers_city'],
                              'postcode' => $order->fields['customers_postcode'],
                              'state' => $order->fields['customers_state'],
                              'country' => $order->fields['customers_country'],
                              'format_id' => $order->fields['customers_address_format_id'],
                              'telephone' => $order->fields['customers_telephone'],
                              'email_address' => $order->fields['customers_email_address']);

      $this->delivery = array('name' => $order->fields['delivery_name'],
                              'company' => $order->fields['delivery_company'],
                              'street_address' => $order->fields['delivery_street_address'],
                              'suburb' => $order->fields['delivery_suburb'],
                              'city' => $order->fields['delivery_city'],
                              'postcode' => $order->fields['delivery_postcode'],
                              'state' => $order->fields['delivery_state'],
                              'country' => $order->fields['delivery_country'],
                              'format_id' => $order->fields['delivery_address_format_id']);

      $this->billing = array('name' => $order->fields['billing_name'],
                             'company' => $order->fields['billing_company'],
                             'street_address' => $order->fields['billing_street_address'],
                             'suburb' => $order->fields['billing_suburb'],
                             'city' => $order->fields['billing_city'],
                             'postcode' => $order->fields['billing_postcode'],
                             'state' => $order->fields['billing_state'],
                             'country' => $order->fields['billing_country'],
                             'format_id' => $order->fields['billing_address_format_id']);

      $index = 0;
      $orders_products = $db->Execute("select orders_products_id, products_id, products_name, products_model,
                                              products_price, products_tax, products_quantity,
                                              final_price, onetime_charges,
                                              product_is_free
                                       from " . TABLE_ORDERS_PRODUCTS . "
                                       where orders_id = '" . (int)$order_id . "'");

	  $products_manufacturers = $db->Execute("select manufacturers_name from " .  TABLE_manufacturers INNER JOIN TABLE_Products . " on products.manufacturers_id = manufacturers_id WHERE products.products_id = '" . + $orders_products['products_id'] . "'" );


      while (!$orders_products->EOF) {
// convert quantity to proper decimals - account history
          if (QUANTITY_DECIMALS != 0) {
            $fix_qty = $orders_products->fields['products_quantity'];
            switch (true) {
            case (!strstr($fix_qty, '.')):
              $new_qty = $fix_qty;
              break;
            default:
              $new_qty = preg_replace('/[0]+$/', '', $orders_products->fields['products_quantity']);
              break;
            }
          } else {
            $new_qty = $orders_products->fields['products_quantity'];
          }

          $new_qty = round($new_qty, QUANTITY_DECIMALS);

          if ($new_qty == (int)$new_qty) {
            $new_qty = (int)$new_qty;
          }

        $this->products[$index] = array('manufacturers' => $products_manufacturers->fields['products_manufacturers'],
        								'qty' => $new_qty,
        		                        'id' => $orders_products->fields['products_id'],
                                        'name' => $orders_products->fields['products_name'],
                                        'model' => $orders_products->fields['products_model'],
                                        'tax' => $orders_products->fields['products_tax'],
                                        'price' => $orders_products->fields['products_price'],
                                        'onetime_charges' => $orders_products->fields['onetime_charges'],
                                        'final_price' => $orders_products->fields['final_price'],
                                        'product_is_free' => $orders_products->fields['product_is_free']);

        $subindex = 0;
        $attributes = $db->Execute("select products_options, products_options_values, options_values_price,
                                           price_prefix,
                                           product_attribute_is_free
                                    from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . "
                                    where orders_id = '" . (int)$order_id . "'
                                    and orders_products_id = '" . (int)$orders_products->
                                    fields['orders_products_id'] . "'");
        if ($attributes->RecordCount()>0) {
          while (!$attributes->EOF) {
            $this->products[$index]['attributes'][$subindex] = array('option' => $attributes->
            fields['products_options'],
                                                                     'value' => $attributes->
                                                                     fields['products_options_values'],
                                                                     'prefix' => $attributes->
                                                                     fields['price_prefix'],
                                                                     'price' => $attributes->
                                                                     fields['options_values_price'],
                                                                     'product_attribute_is_free' =>
                                                                     $attributes->
                                                                     fields['product_attribute_is_free']);

            $subindex++;
            $attributes->MoveNext();
          }
        }
        $index++;
        $orders_products->MoveNext();
      }
    }
  }
?>

should i post my invoice.php code too? i had to modify that file too.

3 Jul 2008, 5:50 PM
#11
machaneko avatar

machaneko

Zen Follower

Join Date:
Apr 2008
Posts:
174
Plugin Contributions:
0

Re: changing the invoice?

lol ok new code again. this time nothing shows up where the manufacturer should be. which is good because now i get no errors.

  $products_manufacturers = $db->Execute("select manufacturers_name from manufacturers INNER JOIN Products on products.manufacturers_id = manufacturers.manufacturers_id WHERE products.products_id = '" . $order->products[$i]['products_id'] . "'" );
7 Jul 2008, 12:10 PM
#12
machaneko avatar

machaneko

Zen Follower

Join Date:
Apr 2008
Posts:
174
Plugin Contributions:
0

Re: changing the invoice?

is anyone going to help? this is important

15 Mar 2009, 7:44 PM
#13
modernm avatar

modernm

New Zenner

Join Date:
Dec 2007
Location:
Hoboken, NJ
Posts:
97
Plugin Contributions:
1

Re: changing the invoice?

Ran into an issue where I needed items that have a qty > 1 to stand out. We kept missing them when processing orders.

Modify "admin/invoice.php"

Replace...

<?php
    for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
      echo '      <tr class="dataTableRow">' . "\n" .
           '        <td class="dataTableContent" valign="top" align="right"><b>' . $order->products[$i]['qty'] . ' x</b></td>' . "\n" .
           '        <td class="dataTableContent" valign="top">' . $order->products[$i]['name'];

With....

<?php
    for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
	
	if ($order->products[$i]['qty'] > 1) {
      echo '      <tr class="dataTableRow">' . "\n" .
           '        <td class="dataTableContent" valign="top" align="right"><b>' . $order->products[$i]['qty'] . ' x</b></td>' . "\n" .
           '        <td class="dataTableContent" valign="top"><b>' . $order->products[$i]['name'] . '</b>';}
		   else {
		   echo '      <tr class="dataTableRow">' . "\n" .
           '        <td class="dataTableContent" valign="top" align="right">' . $order->products[$i]['qty'] . ' x</td>' . "\n" .
           '        <td class="dataTableContent" valign="top">' . $order->products[$i]['name'];
		   }
7 Jul 2009, 5:22 AM
#14
raquelann avatar

raquelann

New Zenner

Join Date:
Jun 2007
Posts:
80
Plugin Contributions:
0

Re: changing the invoice?

This might be a "der" question, but in what way is a developement version of the site set up - do you just allocate a different name to distinguish the two - is it that simple, or more involved. I like this idea and would like to give it a go.