Jump to content
Sign in to follow this  
stratula

extra field for VAT ID in create_account

Recommended Posts

2.3.4.1 CE BS responsive / PHP 7.1.15

Hello,
i want to make an extra field in create_account for VAT ID below company.
It should be as option like company.

The problem is that i do not understand of all what is to do.

I'm sure to start in create_account and make changes like this:

in catalog/create_account.php on line: 33

    if (ACCOUNT_COMPANY == 'true') $company = tep_db_prepare_input($_POST['company']);

to:

    if (ACCOUNT_COMPANY == 'true') $company = tep_db_prepare_input($_POST['company']);
    if (ACCOUNT_VAT-ID == 'true') $vat-id = tep_db_prepare_input($_POST['vat-id']);

 

on line: 196

      if (ACCOUNT_COMPANY == 'true') $sql_data_array['entry_company'] = $company;

to

      if (ACCOUNT_COMPANY == 'true') $sql_data_array['entry_company'] = $company;
	  if (ACCOUNT_VAT-ID == 'true') $sql_data_array['entry_vat-id'] = $vat-id;

 

on line: 346

<?php
  if (ACCOUNT_COMPANY == 'true') {
?>

  <h2 class="h3"><?php echo CATEGORY_COMPANY; ?></h2>
  
  <div class="contentText">
    <div class="form-group">
      <label for="inputCompany" class="control-label col-sm-3"><?php echo ENTRY_COMPANY; ?></label>
      <div class="col-sm-9">
        <?php
        echo tep_draw_input_field('company', NULL, 'id="inputCompany" placeholder="' . ENTRY_COMPANY_TEXT . '"');
        ?>
      </div>
    </div>
  </div>

<?php
  }
?>

to

<?php
  if (ACCOUNT_COMPANY == 'true') {
?>

  <h2 class="h3"><?php echo CATEGORY_COMPANY; ?></h2>
  
  <div class="contentText">
    <div class="form-group">
      <label for="inputCompany" class="control-label col-sm-3"><?php echo ENTRY_COMPANY; ?></label>
      <div class="col-sm-9">
        <?php
        echo tep_draw_input_field('company', NULL, 'id="inputCompany" placeholder="' . ENTRY_COMPANY_TEXT . '"');
        ?>
      </div>
    </div>
  </div>

<?php
  }
?>

<?php
  if (ACCOUNT_VAT-ID == 'true') {
?>

  <h2 class="h3"><?php echo CATEGORY_VAT-ID; ?></h2>
  
  <div class="contentText">
    <div class="form-group">
      <label for="inputVAT-ID" class="control-label col-sm-3"><?php echo ENTRY_VAT-ID; ?></label>
      <div class="col-sm-9">
        <?php
        echo tep_draw_input_field('vat-id', NULL, 'id="inputVAT-ID" placeholder="' . ENTRY_VAT-ID_TEXT . '"');
        ?>
      </div>
    </div>
  </div>

<?php
  }
?>

 

After this i think in admin/customers.php making the same kind of changes and of course the languages files.

But from this point i need help, i don't know what else files have to be change and how to write the sql for dbase.

Any kind of help for this would be nice

thx

Stefan

 

Share this post


Link to post
Share on other sites

There's an addon that does this for 2.3.4. Unfortunately apps site doesn't allow searching for 3 letter words so you'll have to find it manuallu.

Share this post


Link to post
Share on other sites

In addition to the changes in create_account.php you'll need to make changes to admin/customers.php the catalogue account section and the SQL that feeds all these.

Share this post


Link to post
Share on other sites

@LeeFoster

Thank you for the infos.

Is it for the account section only the address_book.php if i want the same rules like company?

The SQL will be a problem for me...😩

@piernas 

The only addon i found is for 2.3.3 and its not the same i want. I need just an extra field straight below company wich follows the same rules like company. No need to make it switchable in admin.

best regards

stefan

Share this post


Link to post
Share on other sites

Old post though

See following
You will need to find and match similar code to insert tax id
Backup first

---------------------
account_edit.php


   if ($error == false) {
    $check_entry_company_tax_id_query = tep_db_query("select entry_company_tax_id from customers where customers_id = '" . (int)$customer_id . "'");
    $check_entry_company_tax_id = tep_db_fetch_array($check_entry_company_tax_id_query);
        
      $sql_data_array = array('customers_firstname' => $firstname,
                              'customers_lastname' => $lastname,
                              'customers_email_address' => $email_address,
                              'customers_telephone' => $telephone,
                              'customers_fax' => $fax,
           'entry_company_tax_id' => $tax);

      if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $gender;
      if (ACCOUNT_DOB == 'true') $sql_data_array['customers_dob'] = tep_date_raw($dob);

    if (ACCOUNT_COMPANY == 'true') {
      if (isset($_POST['company_tax_id']) && tep_not_null($_POST['company_tax_id']) && !tep_not_null($check_entry_company_tax_id['entry_company_tax_id'])) {
        $sql_data_array['entry_company_tax_id'] = tep_db_prepare_input($_POST['company_tax_id']);
      }
    }


---------------------------

  $account_query = tep_db_query("select customers_gender, customers_firstname, customers_lastname, customers_dob, customers_email_address, customers_telephone, customers_fax, entry_company_tax_id from customers where customers_id = '" . (int)$customer_id . "'");
  $account = tep_db_fetch_array($account_query);

  $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link('account.php', '', 'SSL'));


---------------------------

      <?php echo tep_draw_input_field('fax', $account['customers_fax'], 'id="inputFax" placeholder="' . ENTRY_FAX_NUMBER . '"'); ?>
    </div>
  </div>
  
  <?php

   if (ACCOUNT_COMPANY == 'true') { 
?>
  <div class="form-group">
    <label for="inputTax" class="control-label col-sm-3"><?php echo ENTRY_COMPANY_TAX_ID; ?></label>
    <div class="col-sm-9">
      <?php echo  tep_draw_input_field('tax', $account['entry_company_tax_id'], 'id="inputTax" placeholder="' . ENTRY_COMPANY_TAX_ID_TEXT . '"'); 
                          } else {
                    echo $account['entry_company_tax_id'];
                    }  ?>
    </div>
  </div>
  <?php
    if ($account['entry_company_tax_id'] > 0) {
?>

    <div class="col-xs-12"><?php echo TEXT_UPDATE_COMPANY_NAME_ENTRIES . tep_draw_button(IMAGE_BUTTON_ACCOUNT_ADDRESS_BOOK, 'far fa-address-book', tep_href_link('address_book.php', '', 'SSL')); ?></div>
    
  <?php   }  ?>


-------------------------------------------
create_account.php


      if (ACCOUNT_DOB == 'true') $sql_data_array['customers_dob'] = tep_date_raw($dob);


      if ( ACCOUNT_COMPANY == 'true' && tep_not_null($company_tax_id)  ) {
      $sql_data_array['entry_company_tax_id'] = $company_tax_id; 
    }
      
      tep_db_perform(TABLE_CUSTOMERS, $sql_data_array);


------------------------------------------


        <?php
        echo tep_draw_input_field('company', NULL, 'id="organization" placeholder="' . ENTRY_COMPANY_OR . '"');
        if (tep_not_null(ENTRY_COMPANY_TEXT)) echo '<span class="help-block">' . ENTRY_COMPANY_TEXT . '</span>';
        ?>
<!-- BOF field for tax id number -->
        <?php
        echo tep_draw_input_field('company_tax_id', NULL, 'id="organization-title" placeholder="' . ENTRY_COMPANY_TAX_ID_OR . '"');
        if (tep_not_null(ENTRY_COMPANY_TAX_ID_TEXT)) echo '<span class="help-block">' . ENTRY_COMPANY_TAX_ID_TEXT . '</span>';
        ?>
<!-- EOF field for tax id number -->


-----------------------------
includes\languages\english.php  (and other languages)
add


define('ENTRY_COMPANY_TAX_ID', 'Company\'s TAX number:');
define('ENTRY_COMPANY_TAX_ID_ERROR', '');
define('ENTRY_COMPANY_TAX_ID_TEXT', '');


-------------------------------
includes\languages\create_account.php
add

define('ENTRY_COMPANY_TAX_ID_OR', 'Company\'s VAT number or leave empty');

-----------------------------

admin\customers.php

$entry_country_id = tep_db_prepare_input($_POST['entry_country_id']);
$entry_company_tax_id = tep_db_prepare_input($_POST['entry_company_tax_id']);
$entry_company = tep_db_prepare_input($_POST['entry_company']);


--------------

        $sql_data_array = array('customers_firstname' => $customers_firstname,
                                'customers_lastname' => $customers_lastname,
                                'customers_email_address' => $customers_email_address,
                                'customers_telephone' => $customers_telephone,
                                'customers_fax' => $customers_fax,
                                'customers_notes' => $customers_notes,
                                'customers_newsletter' => $customers_newsletter,
                                'customers_wholesale' => $customers_wholesale,

        'entry_company_tax_id' => $entry_company_tax_id);
 

        if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $customers_gender;

--------------------

          $customers_query = tep_db_query("select c.customers_id, c.customers_gender, c.customers_firstname, c.customers_lastname, c.customers_dob, c.customers_email_address, a.entry_company, a.entry_street_address, a.entry_street_address_2, a.entry_suburb, a.entry_postcode, a.entry_city, a.entry_state, a.entry_zone_id, a.entry_country_id, c.entry_company_tax_id, c.customers_telephone, c.customers_fax, c.customers_newsletter, c.customers_wholesale, c.customers_default_address_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a on c.customers_default_address_id = a.address_book_id where a.customers_id = c.customers_id and c.customers_id = '" . (int)$_GET['cID'] . "'"); 

        $customers = tep_db_fetch_array($customers_query);
        $cInfo = new objectInfo($customers);


----------------------------

        <td colspan="2" class="formAreaTitle"><?php echo CATEGORY_COMPANY; ?></td>
      </tr>
      <tr>
        <td colspan="2" class="formArea"><table border="0" cellspacing="2" cellpadding="2">
          <tr>
            <td class="main"><?php echo ENTRY_COMPANY; ?></td>
            <td class="main">
<?php
    if ($error == true) {
      echo $cInfo->entry_company . tep_draw_hidden_field('entry_company');
    } else {
      echo tep_draw_input_field('entry_company', $cInfo->entry_company, 'maxlength="64"');
    }
?></td>
          </tr>
          <tr>
            <td class="main"><?php echo ENTRY_COMPANY_TAX_ID; ?></td>
            <td class="main">
<?php
    if ($error == true) {
      if ($entry_company_tax_id_error == true) {
        echo tep_draw_input_field('entry_company_tax_id', $cInfo->entry_company_tax_id, 'maxlength="32"') . '&nbsp;' . ENTRY_COMPANY_TAX_ID_ERROR;
      } else {
        echo $cInfo->entry_company . tep_draw_hidden_field('entry_company_tax_id');
      }
    } else {
      echo tep_draw_input_field('entry_company_tax_id', $cInfo->entry_company_tax_id, 'maxlength="32"');
      }
?></td>
          </tr>


------------------------
admin\invoice.php


  include('includes/classes/order.php');
  $order = new order($oID);
  
$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'];


----------------------

    <td><table border="0" cellspacing="0" cellpadding="2">
      <tr>
        <td class="main"><strong><?php echo ENTRY_PAYMENT_METHOD; ?></strong></td>
        <td class="main" width="200px"><?php echo $order->info['payment_method']; ?></td> 
        <td class="main" width="400px"><strong><?php echo ENTRY_COMPANY_TAX_ID; ?></strong> <?php echo $tax_id; ?></td>


---------------------
admin\orders.php

                <td class="main"><?php echo tep_address_format($order->customer['format_id'], $order->customer, 1, '', '<br />'); ?>

              <?php
$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 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'];


---------------------
admin\packingslip.php
add

$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']; 


then somewhere add the tax id like:

            <td class="main"><b><?php echo ENTRY_SHIP_TO; ?></b></td>
          </tr>
          <tr>
            <td class="main"><?php echo tep_address_format($order->delivery['format_id'], $order->delivery, 1, '', '<br>'); ?></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  </tr>
  <tr>
    <td><table border="0" cellspacing="0" cellpadding="2">
      <tr>
        <td class="main" width="300px"><strong><?php if ($tax_id >"1") echo ENTRY_COMPANY_TAX_ID;?></strong> <?php echo $tax_id; ?></td>
        <td class="main"><b><?php echo ENTRY_PAYMENT_METHOD; ?></b></td>
        <td class="main"><?php echo $order->info['payment_method']; ?></td>
      </tr>

---------------
admin\includes\languages\english.php
add

define('ENTRY_COMPANY_TAX_ID', 'Company TAX Number:');
define('ENTRY_COMPANY_TAX_ID_ERROR', '');

-------------------

with phpmyadmin
sql
ALTER TABLE customers ADD entry_company_tax_id varchar(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL;


Thanks to all source contributors, 2.3.4 Edge just works fine

https://github.com/gburton/Responsive-osCommerce/archive/master.zip

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×