Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Database entries help


Peper

Recommended Posts

Please help

 

With 2.3.4 TAX or VAT field when new customer registers.

The field gets updated in the customers table as entry_customers_tax_id

 

So now i need to get that tax number to display on a PDF invoice.

Problem is its in the customers table and not in the orders table

 

How to get the data to display pls?

 

I have tried many ways and given up on this.

 

added to pdfinvoice.php:

 

$tax_id_query = tep_db_query("select distinct entry_company_tax_id from " . TABLE_CUSTOMERS . " where entry_company_tax_id = '" . $customers['entry_customers_tax_id'] . "'");
$company_tax_id=tep_db_fetch_array($tax_id_query);
$tax_id=$company_tax_id[entry_company_tax_id];
 
then the last output part:
 
$pdf->Text(58,$pos_y+17.5, $tax_id->customer['company_tax_id'], $tax_id->entry_company_tax_id);

 

Getting the Phoenix off the ground

Link to comment
Share on other sites

$tax_id_query = tep_db_query("select entry_company_tax_id from " . TABLE_CUSTOMERS . " where customers_id = '" . $customers['customers_id'] . "'");

Something like that should do it.

Link to comment
Share on other sites

Henry @@wHiTeHaT

 

Can I ask you for the catalog side I cannot get this to work either(admin is fine)

 

 

 

$tax_id_query = tep_db_query("select entry_company_tax_id from " . TABLE_CUSTOMERS . " where customers_id = '" . $customers['customers_id'] . "'");
$company_tax_id=tep_db_fetch_array($tax_id_query);
$tax_id=$company_tax_id[entry_company_tax_id];
 
then the output part:
 
$pdf->Text(13,$pos_y+17,  $order->customer['company_tax_id'], $company_tax_id[entry_company_tax_id]);

 

I tried a few like below but not working as well:

$tax_id->customer['company_tax_id'], $tax_id->entry_company_tax_id);

Getting the Phoenix off the ground

Link to comment
Share on other sites


$tax_id_query = tep_db_query("select entry_company_tax_id from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");

$company_tax_id=tep_db_fetch_array($tax_id_query);

$tax_id=$company_tax_id[entry_company_tax_id];

Link to comment
Share on other sites

  • 1 month later...

@@wHiTeHaT

 

Ok, this did not go as planned

It uses the first tax number that comes up in database as it seems, all orders got the same TAX number

 

 

$tax_id_query = tep_db_query("select entry_company_tax_id from " . TABLE_CUSTOMERS . " where entry_company_tax_id != '" . (int)$customer_id . "'");
$company_tax_id=tep_db_fetch_array($tax_id_query);
$tax_id=$company_tax_id['entry_company_tax_id'];
 
 
<strong><?php echo ENTRY_COMPANY_TAX_ID; ?></strong> <?php echo $tax_id; ?>
 
Anyone that can help with this please!

Getting the Phoenix off the ground

Link to comment
Share on other sites

I'm not an expert at database queeries, but since you're stumped I'll try.  You changed your query from what Whitehat had given you.  In the query you listed you're asking it for the tax id number that doesn't equal the customer number.  So, it gives you the first number that doesn't equal the customer number.  Look at Whitehat's last post.  Did you change it on purpose?
 

I'm not really a dog.

Link to comment
Share on other sites

I did a little experimenting on my test server.  I'm not positive but I think the problem, but I think the problem may be the missing ' on the last line of the query.  Try this and let me know if it works.  I did this on a test page where I set $customer_id and only had the query below. 

$tax_id_query = tep_db_query("select entry_company_tax_id from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
$company_tax_id=tep_db_fetch_array($tax_id_query);
$tax_id=$company_tax_id['entry_company_tax_id'];

I'm not really a dog.

Link to comment
Share on other sites

Here's the test page I made and I inserted a tax id for the customer number.  It echo's on the test page so you try this and build from there.  I don't know what the rest of your page is but you might try to make sure it echos a customer number.

include 'includes/application_top.php';

$customer_id = 501;

$tax_id_query = tep_db_query("select entry_company_tax_id from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
$company_tax_id=tep_db_fetch_array($tax_id_query);
$tax_id=$company_tax_id['entry_company_tax_id'];

echo $tax_id;

I'm not really a dog.

Link to comment
Share on other sites

@@John W

Ok, think I've got it now John Many thanks with a bump in right direction

With your $customer_id = 501; the customer ID is needed

 

so then when I do below it works like a charm.

Now pdf and so also to sort out

 

  $oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);
  $orders_query = tep_db_query("select orders_id, customers_id from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");
$customer_id = tep_db_fetch_array($orders_query);
$orders=$customer_id['customers_id'];
$customer_id = $orders;
  
$tax_id_query = tep_db_query("select entry_company_tax_id from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
$company_tax_id=tep_db_fetch_array($tax_id_query);
$tax_id=$company_tax_id['entry_company_tax_id'];
 
and then echo part
<strong><?php echo ENTRY_COMPANY_TAX_ID; ?></strong><?php echo $tax_id; ?>

Getting the Phoenix off the ground

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...