![]() |
Re: Additional fields for address book
Quote:
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! |
Re: Additional fields for address book
Quote:
FLC = Fast Lane Checkout OPC = One Page Checkout |
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. |
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 |
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... |
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}> {/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}> {/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> {$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> {$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> {$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> {$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} |
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. |
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 ... |
Re: Additional fields for address book
Is this part of XC 4.5.5 as Qualiteam promissed?
|
Re: Additional fields for address book
Quote:
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 |
Re: Additional fields for address book
Praise Jesus! This was one of the most requested feature for XC. Great to have it on board.
Thanks for letting me know. |
Re: Additional fields for address book
Quote:
The way they added it doesn't really cut it. You will still have to do like Steve posted to have a decent Company Name field. In my opinion it is borderline inexcusable that the fields are not manageable in the back-end... we should be able to add anywhere and reorder. |
Re: Additional fields for address book
What you told me is really sad. Another unfinished job from QT?
|
Re: Additional fields for address book
Quote:
You can add an additional 'Company' field to be displayed in any section - this can be done on the User Profiles page: - Address book (billing & shipping address) - Personal information - Additional information What is wrong with it? However, to reorder the fields, you will still have to customize your X-Cart templates. |
Re: Additional fields for address book
Quote:
|
Re: Additional fields for address book
Ok I have done reading 10 pages of this threads. I installed new version 4.5.5. This is new store with no customer data yet so it is the best time to do modifications and I want to start things right.
I tried Sergey suggested. I added 'Company' Field under additional field to appear in Address book section. Then I edit template file to reorder so Company field show up on the top part. The form looks the way I wants. But I have problem at checkout. For One Page Checkout, company field does not show at checkout page. But when the order is placed, it shows up on invoice page as well as on admin order detail page. So which template do I edit to have Company name show up on checkout page? For Fast Lane Checkout, only the company name from default address shows up on checkout page. If you change the address to another address n the address book, company name does not change and still show the one form default address. On the invoice and order detail page, it shows correct company name for most cases. But when shipping a address is not default address, company name for billing show up as blank. I think this problem is more like bug in coding. If so please move this to proper forum. I also looked at Steve code to hard code Company name field. However will it work with One page checkout or fast lane checkout? I do not see any file under those modules are being edited. |
Re: Additional fields for address book
Quote:
|
Re: Additional fields for address book
I was able to tweak the code to make Company Name appear in OPC checkout page. Somehow value of additional_field.avail is not coming out as expected in following two files.
common_files/customer/main/address_details_html.tpl common_files/modules/One_Page_Checkout/profile/address_fields.tpl If you remove that from if statement, it shows up. For example, I changed Quote:
Quote:
I do not understand why $field.avail value is not 'Y' as expected. I traced the code to func_get_additional_fields function but not sure how it does not pass the value as Y. Again I am not programmer. May be someone can explain. Quote:
|
Re: Additional fields for address book
This patch seems to have an issue with 4.4.5 and FLC. Additional fields are not shown for logged in customers editing an existing address book entry. Add New Address shows the fields fine.
|
Re: Additional fields for address book
If at least one new field was required among the existing fields (hard coding required), and some rearrangement of the existing fields was necessary, AND a third address set of fields was required, would it be best to hard code, or utilize the additional fields feature for the third address set of fields, assuming all the new third address fields would be at the bottom?
|
Re: Additional fields for address book
1 Attachment(s)
Thanks Steve!
In version 4.6.3, the setting up the company address field as an "additional address field" in user profile doesn't allow it to be put in the correct field order for address labels (as many now know). So I used your hard coding of the Company field as per your coding (slightly modified as 4.6.3 has the bugs removed). I don't really understand why but I just couldn't get the company field to show anywhere, even after clearing caches. None of the array functions would pick it up. Then, in PHPMyadmin I searched xcart_config table for "address_book_fields" I decided to manually insert the company field Quote:
So it now contains : Quote:
and everything started working correctly - including the field showing in User Profiles and it the avail/req'd checkboxes also work - see attached. In 4.6.3, userprofiles.php call for $default_address_book_fields; but func.user.php calls for $default_address_fields - I think this is where the hard-coding of the fields is complicated a little. Hope this helps someone! |
Re: Additional fields for address book
Quote:
Just delete the entry for address fields in config table - XC will generate it again from the init.php values and include the changes you have made for "company" field |
Re: Additional fields for address book
Cheers & Thanks.
So it is another cache - DB cache. As you replied I read http://forum.x-cart.com/showthread.php?t=58832&page=2&highlight=func_get_d efault_fields Appears you need to do this in PHPMyAdmin, as clearing x-cart cache doesn't do it. Much appreciated:lol: |
All times are GMT -8. The time now is 05:18 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.