Jump to content



Latest News: (loading..)

- - - - -

Total in WORDS


This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1   Kiwibiker

Kiwibiker
  • Members
  • 9 posts

Posted 15 April 2004 - 11:39 PM

Hi,
I am working on dispalying the Total of the order in words, so I could print it on invoices and shipping letters. The php script changing numbers into words is already prepared but I can't find out in what variable in invoice.php the TOTAL of the order is stored :-/  My script needs it to work properly.

Thank you in advance!!

PS
you can see the script itself here:

txt file    unfortunately in Polish only ;-)

#2   zzfritz

zzfritz
  • Members
  • 501 posts

Posted 16 April 2004 - 07:36 AM

What you want is not quite as easily achieved as you expect.

The script admin/invoice.php (v1.6) lists the components of the order total (subtotal, tax, shipping, etc) with the "for" loop at line 129.  It takes the text description of the order total components and their text values from the order class $order->totals[$i]['title'] and $order->totals[$i]['text'].

These two entries are from the orders_total table, indexed by the orders_id, and read by the query in admin/includes/classes/order.php at line 30.

But you presumably require the digital form of the value, the entry named 'value', which is not generally visibile through the class.  To do that, you would have to modify the query referred to above and also add this element to the $this->totals[] array built at line 32:  'value' => $totals['value'].

Change this
$totals_query = tep_db_query("select title, text from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' order by sort_order");
      while ($totals = tep_db_fetch_array($totals_query)) {
        $this->totals[] = array('title' => $totals['title'],
                                'text' => $totals['text']);
      }
to this
$totals_query = tep_db_query("select title, text, value from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' order by sort_order");
      while ($totals = tep_db_fetch_array($totals_query)) {
        $this->totals[] = array('title' => $totals['title'],
                                'text' => $totals['text'],
                                'value' => $totals['value]);
      }

(I suggest browsing your orders_total table with phpMyAdmin to see what these entires look like, and this should be clearer.)

That change having been made in classes/order.php, the value will be visible in invoice.php (like the title and text) as $order->totals[$i]['value'].  You will have to detect which row is the total, capture the value, then do the conversion as proposed and echo it out.

Good luck.

#3   Kiwibiker

Kiwibiker
  • Members
  • 9 posts

Posted 16 April 2004 - 12:10 PM

I made the change in admin/.../classes/order.php and added
        
$order->totals[$i]['value']  to the invoice.php (just under the title and text)  but can't sort out capturing the value. I use php for just about 2 weeks so I'm a complete greenhorn yet :-/    

I'd like to attribute the value to $to variable. What should I do?

$to= ???


Thanks for patience....