Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Additional fields for address book

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #81  
Old 11-02-2012, 05:58 AM
 
GreatLakesVacuum GreatLakesVacuum is offline
 

eXpert
  
Join Date: Jan 2009
Posts: 286
 

Default Re: Additional fields for address book

Quote:
Originally Posted by totaltec
Steel,
I just tested this method of positioning, and it works like a charm for OPC and the admin side. In the address book (when accessed from my account tab not OPC) it does not automatically re-position the fields, because they are hard coded into the template.

An easy fix though, moving the fields in the templates are easy as pie. To edit the address book fields you can look at /common_files/customer/main/address_fields.tpl

You can see it working at my test site: http://trainingpen.com

Moving the fields in the address book or in FLC has never been a problem. It is OPC where this change is difficult, and requires some custom code like I suggested above. If you are using FLC then you just change the language variable for fax, and reorder the fields in the template. No need for any hair pulling.

In OPC the fields are populated in the order that they are pulled from the DB.

What is FLC and what is OPC?

I am implementing your suggested change above but I don't know what those stand for.

I went to your test site and looked at it, you just did the moving of Fax right? (as it is not renamed)

I changed the order of them in address_fields.tpl but I am not seeing any indication that it was the right template?!
EDIT: I am an idiot and was not editing the RIGHT address_fields.tpl file

EDIT2: Can you tell me what address_details_html.tpl controls?
EDIT3: Figured it out, I'll stop posting now!
__________________
X-Cart 4.5.4 Gold (Live Business Site)
X-Cart 5.1.9 Business (In Development Now)
Reply With Quote
  #82  
Old 11-02-2012, 06:14 AM
  photo's Avatar 
photo photo is offline
 

X-Wizard
  
Join Date: Feb 2006
Location: UK
Posts: 1,146
 

Default Re: Additional fields for address book

Quote:
Originally Posted by GreatLakesVacuum
What is FLC and what is OPC?

FLC = Fast Lane Checkout
OPC = One Page Checkout
__________________
v4.1.10
In Dev v4.5.x


"If you don't keep an eye on your business, someone else will."
Reply With Quote

The following user thanks photo for this useful post:
GreatLakesVacuum (11-02-2012)
  #83  
Old 11-02-2012, 06:27 AM
 
GreatLakesVacuum GreatLakesVacuum is offline
 

eXpert
  
Join Date: Jan 2009
Posts: 286
 

Default Re: Additional fields for address book

We are using OPC (Thanks photo!) and I made the changes in init.php and in address_fields.tpl, and in address_details_html.tpl and everything looks fine.

I renamed lbl_fax to Company name and set its value to required

Anything else I am missing for OPC?

I am kinda disappointed I had to do this when X-Cart said 4.5.4 had it included, but they seem to like to lie to us.
__________________
X-Cart 4.5.4 Gold (Live Business Site)
X-Cart 5.1.9 Business (In Development Now)
Reply With Quote
  #84  
Old 11-02-2012, 05:28 PM
 
Steel Steel is offline
 

eXpert
  
Join Date: Dec 2006
Posts: 253
 

Default Re: Additional fields for address book

There are several factors that need to be contemplated prior to a decision about how to deal with address book field additions.

1) Do new address fields need to be positioned between the stock field listings, or will new additions added/positioned at the bottom of the stock field listings be acceptable?
2) What checkout system is being utilized (standard, FLC, OPC, other?) and is there any chance that a merchant might switch from one system to another in the future?
3) What is the current number of address book field additions required, and what is the chance that additional ones will be required in the future?
4) Is the Import/Export of address book field additions desired, and if so, is the stock X-Cart Import/Export function desired, or can a merchant utilize a back-end option (such as cPanel) to accomplish the task, (or modify X-Cart code relating to the Import/Export function).

So, taking into consideration the broadest application (FLC + OPC + 1 (or more) address field addition/name change + allowance for leaving open the possibility for 1 or possibly 2 (fax & title?) future address field addition/name change), and given that Export/Import of the address book information is desired/required, then the following hard coding looks to be the best practice:
1) New database fields need to be added and arranged as one would want them arranged on the OPC page, and several files need to have the fields redefined.
2) Various template files/html forms will need to have blocks of code added for the field additions, and possibly be rearranged.

If positioning additional fields at the bottom of the stock address book field listings is acceptable, and the stock X-Cart function for the Import/Export of the new address book field additions is not required, then the recent X-Cart Address Book Improvement should do the job.

In between the X-Cart Address Book Improvement and what I presume to be the best practice of hard coding, depending on which above listed factors are required, there are some fairly simple code hacks that can accomplish the job.

Is all of this a fair assessment?

Reference discussions:
Adding company field in address book
http://forum.x-cart.com/showthread.php?t=58364&highlight=address_fields.tp l

Changes to address fields and layout in OPC
http://forum.x-cart.com/showthread.php?t=58832&highlight=address_fields.tp l
__________________
X-Cart Gold v4.6.6
Reply With Quote
  #85  
Old 11-02-2012, 08:02 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default Re: Additional fields for address book

How to hard code company name (or any other field) following current XC logic. This adds company name after first/last names - switch places if you need it to be different position. Be careful changing php/tpl files and database - backup, backup, backup. This is tested to work on 4.5.x but I take no responsibility for your action. Also note - this will not change payment methods and will not include company field when sending info to PP or other payment gateways as well as X-Payments. If you need this new field to be included there as well you have to modify the approptiate php file for that payment method

1. run this sql
ALTER TABLE `xcart_orders` ADD `b_company` VARCHAR( 128 ) NOT NULL DEFAULT '' AFTER `b_lastname`;
ALTER TABLE `xcart_orders` ADD `s_company` VARCHAR( 128 ) NOT NULL DEFAULT '' AFTER `s_lastname`;
ALTER TABLE `xcart_address_book` ADD `company` VARCHAR( 128 ) NOT NULL DEFAULT '' AFTER `lastname`;

2. open init.php and find

'lastname' => array(
'avail' => array('A' => 'N', 'P' => 'N', 'B' => 'N', 'C' => 'Y', 'H' => 'Y'),
'required' => array('A' => 'N', 'P' => 'N', 'B' => 'N', 'C' => 'Y', 'H' => 'Y')
),

and after add

// addded by CFL Systems (also 'company' field added to xcart_address_book table)
'company' => array(
'avail' => array('A' => 'N', 'P' => 'N', 'B' => 'N', 'C' => 'Y', 'H' => 'Y'),
'required' => array('A' => 'N', 'P' => 'N', 'B' => 'N', 'C' => 'N', 'H' => 'N')
),
// addded by CFL Systems (also 'company' field added to xcart_address_book table)


3. open include/func/func.order.php and find


$_fields = array (
'title',
'firstname',
'lastname',
'address',
'city',
'county',
'state',
'country',
'zipcode',
'zip4',
'phone',
'fax',
);

and change to

$_fields = array (
'title',
'firstname',
'lastname',
'company', // added by CFL Systems for company name
'address',
'city',
'county',
'state',
'country',
'zipcode',
'zip4',
'phone',
'fax',
);


4. open modules/Advanced_Order_Management/func.php and find

$_fields = array (
'title',
'firstname',
'lastname',
'email',
'url',
'company',
'tax_number',
'tax_exempt',
'membershipid'
);

and change to

$_fields = array (
'title',
'firstname',
'lastname',
'company', // added by CFL Systems for company name
'email',
'url',
'company',
'tax_number',
'tax_exempt',
'membershipid'
);

then find

$_fields = array (
'title',
'firstname',
'lastname',
'address',
'city',
'county',
'state',
'country',
'zipcode',
'zip4',
'phone',
'fax',
);

and change to

$_fields = array (
'title',
'firstname',
'lastname',
'company', // added by CFL Systems for company name
'address',
'city',
'county',
'state',
'country',
'zipcode',
'zip4',
'phone',
'fax',
);

5. open modules/Advanced_Order_Management/func.edit.php and find

'b_lastname' => $userinfo['b_lastname'],

and after add

'b_company' => $userinfo['b_company'], // added by CFL Systems for company name

then find

's_lastname' => $userinfo['s_lastname'],

and after add

's_company' => $userinfo['s_company'], // added by CFL Systems for company name

CONTINUE...
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #86  
Old 11-02-2012, 08:04 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default Re: Additional fields for address book

6. open skin/common_files/main/address_fields.tpl and find

{if $address_fields.lastname.avail eq 'Y'}
<tr>
<td class="data-name"><label for="lastname{$id}">{$lng.lbl_last_name}</label></td>
<td{if $address_fields.lastname.required eq 'Y'} class="data-required"{/if}>{if $address_fields.lastname.required eq 'Y'}*{/if}</td>
<td>
<input type="text" id="lastname{$id}" name="address_book[{$id}][lastname]" size="32" maxlength="128" value="{$address.lastname|escape}" />
</td>
</tr>
{/if}

and after add

{* added by CFL Systems for company name *}
{if $address_fields.company.avail eq 'Y'}
<tr>
<td class="data-name"><label for="company{$id}">{$lng.lbl_company}</label></td>
<td{if $address_fields.company.required eq 'Y'} class="data-required"{/if}>{if $address_fields.company.required eq 'Y'}*{/if}</td>
<td>
<input type="text" id="company{$id}" name="address_book[{$id}][company]" size="32" maxlength="128" value="{$address.company|escape}" />
</td>
</tr>
{/if}
{* added by CFL Systems for company name *}


7. open skin/common_files/customer/main/address_fields.tpl and find

{if $default_fields.lastname.avail eq 'Y'}
<tr>
<td class="data-name"><label for="{$id_prefix}lastname">{$lng.lbl_last_name}</label></td>
<td{if $default_fields.lastname.required eq 'Y'} class="data-required">*{else}>&nbsp;{/if}</td>
<td>
<input type="text" id="{$id_prefix}lastname" name="{$name_prefix}[lastname]" size="32" maxlength="128" value="{$address.lastname|escape}" />
</td>
</tr>
{/if}

and after add

{* added by CFL Systems for company name *}
{if $default_fields.company.avail eq 'Y'}
<tr>
<td class="data-name"><label for="{$id_prefix}company">{$lng.lbl_company}</label></td>
<td{if $default_fields.company.required eq 'Y'} class="data-required">*{else}>&nbsp;{/if}</td>
<td>
<input type="text" id="{$id_prefix}company" name="{$name_prefix}[company]" size="32" maxlength="128" value="{$address.company|escape}" />
</td>
</tr>
{/if}
{* added by CFL Systems for company name *}


8. open skin/common_files/customer/main/address_details_html.tpl and find

{if $default_fields.lastname and $address.lastname ne ''}{$address.lastname|escape}{/if}

and after add

{* added by CFL Systems for company name *}
{if $default_fields.company and $address.company ne ''}<br/>{$address.company|escape}{/if}
{* added by CFL Systems for company name *}


9. open skin/common_files/mail/html/order_invoice.tpl and find

{if $_userinfo.default_address_fields.lastname}
<tr>
<td><strong>{$lng.lbl_last_name}:</strong> </td>
<td>{$order.b_lastname|escape}</td>
</tr>
{/if}

after add

{* added by CFL Systems for company name *}
{if $_userinfo.default_address_fields.company}
<tr>
<td><strong>{$lng.lbl_company}:</strong> </td>
<td>{$order.b_company|escape}</td>
</tr>
{/if}
{* added by CFL Systems for company name *}

then find

{if $_userinfo.default_address_fields.lastname}
<tr>
<td><strong>{$lng.lbl_last_name}:</strong> </td>
<td>{$order.s_lastname|escape}</td>
</tr>
{/if}

and after add

{* added by CFL Systems for company name *}
{if $_userinfo.default_address_fields.company}
<tr>
<td><strong>{$lng.lbl_company}:</strong> </td>
<td>{$order.s_company|escape}</td>
</tr>
{/if}
{* added by CFL Systems for company name *}


10. open skin/common_files/main/order_info.tpl and find

{if $customer.default_address_fields.lastname}
<tr valign="top">
<td>&nbsp;&nbsp;{$lng.lbl_last_name}</td>
<td>{$customer.b_lastname|escape}</td>
</tr>
{/if}

after add

{* added by CFL Systems for company name *}
{if $customer.default_address_fields.company}
<tr valign="top">
<td>&nbsp;&nbsp;{$lng.lbl_company}</td>
<td>{$customer.b_company|escape}</td>
</tr>
{/if}
{* added by CFL Systems for company name *}

then find

{if $customer.default_address_fields.lastname}
<tr valign="top">
<td>&nbsp;&nbsp;{$lng.lbl_last_name}</td>
<td>{$customer.s_lastname|escape}</td>
</tr>
{/if}

and after add

{* added by CFL Systems for company name *}
{if $customer.default_address_fields.company}
<tr valign="top">
<td>&nbsp;&nbsp;{$lng.lbl_company}</td>
<td>{$customer.s_company|escape}</td>
</tr>
{/if}
{* added by CFL Systems for company name *}


11. open skin/common_files/modules/Advanced_Order_Management/edit_customer.tpl and find

{if $address_fields.lastname.avail eq 'Y'}
<tr{cycle name=c2 values=', class="TableSubHead"'}>
<td>{$lng.lbl_last_name}</td>
<td><input type="text" name="customer_info[b_lastname]" size="32" maxlength="128" value="{$cart_customer.b_lastname|escape}" /></td>
<td>{$customer.b_lastname}</td>
</tr>
{/if}

and after add

{* added by CFL Systems for company name *}
{if $address_fields.company.avail eq 'Y'}
<tr{cycle name=c2 values=', class="TableSubHead"'}>
<td>{$lng.lbl_company}</td>
<td><input type="text" name="customer_info[b_company]" size="32" maxlength="128" value="{$cart_customer.b_company|escape}" /></td>
<td>{$customer.b_company}</td>
</tr>
{/if}
{* added by CFL Systems for company name *}

then find

{if $address_fields.phone.avail eq 'Y'}
<tr{cycle name=c4 values=', class="TableSubHead"'}>
<td>{$lng.lbl_phone}</td>
<td><input type="text" name="customer_info[b_phone]" size="32" maxlength="32" value="{$cart_customer.b_phone|escape}" /></td>
<td>{$customer.s_phone}</td>
</tr>
{/if}
{if $address_fields.fax.avail eq 'Y'}
<tr{cycle name=c4 values=', class="TableSubHead"'}>
<td>{$lng.lbl_fax}</td>
<td><input type="text" name="customer_info[b_fax]" size="32" maxlength="32" value="{$cart_customer.b_fax|escape}" /></td>
<td>{$customer.s_fax}</td>
</tr>
{/if}

and change to

{if $address_fields.phone.avail eq 'Y'}
<tr{cycle name=c4 values=', class="TableSubHead"'}>
<td>{$lng.lbl_phone}</td>
<td><input type="text" name="customer_info[b_phone]" size="32" maxlength="32" value="{$cart_customer.b_phone|escape}" /></td>
<td>{$customer.b_phone}</td> {* CFL Systems - fixed XC bug *}
</tr>
{/if}
{if $address_fields.fax.avail eq 'Y'}
<tr{cycle name=c4 values=', class="TableSubHead"'}>
<td>{$lng.lbl_fax}</td>
<td><input type="text" name="customer_info[b_fax]" size="32" maxlength="32" value="{$cart_customer.b_fax|escape}" /></td>
<td>{$customer.b_fax}</td> {* CFL Systems - fixed XC bug *}
</tr>
{/if}

then find

{if $address_fields.lastname.avail eq 'Y'}
<tr{cycle name=c3 values=', class="TableSubHead"'}>
<td>{$lng.lbl_last_name}</td>
<td><input type="text" name="customer_info[s_lastname]" size="32" maxlength="128" value="{$cart_customer.s_lastname|escape}" /></td>
<td>{$customer.s_lastname}</td>
</tr>
{/if}

and after add

{* added by CFL Systems for company name *}
{if $address_fields.company.avail eq 'Y'}
<tr{cycle name=c2 values=', class="TableSubHead"'}>
<td>{$lng.lbl_company}</td>
<td><input type="text" name="customer_info[s_company]" size="32" maxlength="128" value="{$cart_customer.s_company|escape}" /></td>
<td>{$customer.s_company}</td>
</tr>
{/if}
{* added by CFL Systems for company name *}

then find

{if $address_fields.country.avail eq 'Y'}
<tr{cycle name=c3 values=', class="TableSubHead"'}>
<td>{$lng.lbl_country}</td>
<td>
<select name="customer_info[s_country]" id="customer_info_s_country" onchange="javascript: check_zip_code_field(this.form['customer_info[s_country]'], this.form['customer_info[s_zipcode]']);">
{section name=country_idx loop=$countries}
<option value="{$countries[country_idx].country_code|escape}"{if $cart_customer.s_country eq $countries[country_idx].country_code or ($countries[country_idx].country_code eq $config.General.default_country and $cart_customer.b_country eq "")} selected="selected"{/if}>{$countries[country_idx].country}</option>
{/section}
</select>
</td>
<td>{$customer.s_countryname}</td>
</tr>
{/if}

and change to

{if $address_fields.country.avail eq 'Y'}
<tr{cycle name=c3 values=', class="TableSubHead"'}>
<td>{$lng.lbl_country}</td>
<td>
<select name="customer_info[s_country]" id="customer_info_s_country" onchange="javascript: check_zip_code_field(this.form['customer_info[s_country]'], this.form['customer_info[s_zipcode]']);">
{section name=country_idx loop=$countries}
<option value="{$countries[country_idx].country_code|escape}"{if $cart_customer.s_country eq $countries[country_idx].country_code or ($countries[country_idx].country_code eq $config.General.default_country and $cart_customer.s_country eq "")} selected="selected"{/if}>{$countries[country_idx].country}</option> {* CFL Systems - fixed XC bug *}
{/section}
</select>
</td>
<td>{$customer.s_countryname}</td>
</tr>
{/if}
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following 5 users thank cflsystems for this useful post:
alinush (11-18-2012), Ben G (07-23-2014), dpcompany (11-24-2014), photo (11-03-2012), Steel (11-03-2012)
  #87  
Old 11-03-2012, 07:16 PM
 
Steel Steel is offline
 

eXpert
  
Join Date: Dec 2006
Posts: 253
 

Default Re: Additional fields for address book

Steve,

That is an impressive detailed explanation. Thanks for sharing your code work!

Seems that in the past, X-Cart commented that positioning of stock fields was a complicated programing task. Would it be poor code practice to hard code a couple "Company" positions, having the ability to name and activate/require information for each on the management side? If this is a possibility, it seems that it would solve 75% of the complaints, and coupled with their recent X-Cart Address Book Improvement and the ability to specify and add new Sections to the xcart_register_addressfields DB, might satisfy 95% of the requirements with only minor custom coding required.

Do you think any significant additional X-Cart development will be dropped at some point in the near future?

Thanks again.
__________________
X-Cart Gold v4.6.6
Reply With Quote
  #88  
Old 11-03-2012, 08:35 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default Re: Additional fields for address book

QT mentioned that it will be "complicated programing task" because of the way address book is coded in the first place. Yes it will be. But if this was coded properly to begin with it wouldn't be such a pain. Right now there are these main fields that are hard coded and as you can see from the code I posted in way too many places. If all this was started in a table and not hardcoded in init.php would have been way easier. I think QT just copied the customer details from earlier versions and turn it into address book in 4.4.x but this created the whole mess...

Following the above logic you can add as many new fields as you want as long as they are named differently.

If in near future QT decides to scrap the address book the way it is right now and re-code it from scratch then all this will not matter. Unfortunatelly I don't see this happening - it was requested since 4.4.x was introduces and still no change so ...
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #89  
Old 04-22-2013, 06:52 AM
  ADDISON's Avatar 
ADDISON ADDISON is offline
 

X-Man
  
Join Date: Jan 2008
Posts: 2,613
 

Default Re: Additional fields for address book

Is this part of XC 4.5.5 as Qualiteam promissed?
__________________
X-Cart Next: Business 5.2 (learning and testing)
X-Cart Classic: Gold and Gold Plus 4.7
Lots of Modules and Customizations
OS in use: Red Hat Enterprise, Fedora, CentOS, Debian, Ubuntu, Linux Mint, Kali Linux
Ideas for Server configuration (basicaly): Nginx/Pound (reverse proxy), Apache/Nginx (webserver), Squid/Varnish (cache server), HHVM or (PHP-FPM + PHP 5.6 + opcache), MariaDB/Percona MySQL Server, Redis (storing sessions)

You can catch my ideas here: http://ideas.x-cart.com
Reply With Quote
  #90  
Old 04-22-2013, 07:22 AM
  rocky's Avatar 
rocky rocky is offline
 

X-Cart team
  
Join Date: Jul 2005
Posts: 719
 

Default Re: Additional fields for address book

Quote:
Originally Posted by ADDISON
Is this part of XC 4.5.5 as Qualiteam promissed?


Yes, it's a part of XC since 4.5.4. This improvement is described in our "X-Cart 4.5.4 released" blog post:

http://www.x-cart.com/blog/xcart-454-released.html
__________________
Alexander Dyachkov,
Director of Customer Success
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 12:59 AM.

   

 
X-Cart forums © 2001-2020