X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   register form in checkout mode - summary (https://forum.x-cart.com/showthread.php?t=14668)

pauldodman 06-20-2005 05:45 AM

register form in checkout mode - summary
 
There are a lot of threads regarding entering names 3 times in the checkout register form. The main one has over 3500 views and 6 pages of discussion. If like me you find this confusing and you need a fix for standard 4.0.13 that covers most requirements, then hopefully this will help. (If you are an administrator and I have started a new topic when I shouldn't, sorry, just trying to make a complicated problem to solve via the forum simpler.)

The main thread (http://forum.x-cart.com/viewtopic.php?t=17146&highlight=profile) branches off to solve the problem for version 3, then for Jon's EzCheckout, making it hard to follow and implement a standard fix.

This post:
  • Saves your customer typing in names more than once in the checkout register form.
    still allows them to enter different names if they want to for Billing and Shipping
    Designed for standard 4.0.13
    Makes changes to the register form in checkout.
    Accounts for fact there are 2 register forms, therefore preserves normal register/create profile form


When customer starts the form, enters First and last name; these are duplicated to Billing Address (but not to Shipping)
Fills in the rest of Billing Address. Click the check box to duplicate name and address to Shipping.
Includes County/State and Country.

Doesn't matter if fields are mandatory, as they will get filled in one way or the other, but doesn't remove them as they may well be needed.


1) Open main/register_personal_info.tpl
Find INPUT fields for firstname and lastname
ADD THIS CODE to end of tag

onChange="populateProfile()"

e.g.
<INPUT type="text" id="firstname" name="firstname" size="32" maxlength="32" value="{$userinfo.firstname}" onChange="populateProfile()">

2) Open main/register_billing_address.tpl
After the last </TR>
add this code

{* ======== COPY BILLING TO SHIPPING MOD ======= *}
{if $action eq "cart"}
<TR>
<TD align="right"></TD>
<TD></TD>
<TD nowrap>
<input type="checkbox" name="copyb" onclick=javascript:copybilling(this.form);>Use {$lng.lbl_billing_address} as {$lng.lbl_shipping_address}


</TD>
</TR>
{/if}
{* ======== COPY BILLING TO SHIPPING MOD ======= *}

3) in skin1, make copybilling.js

function InitSaveVariables_shipping(form){
s_firstname = form.s_firstname.value;
s_lastname = form.s_lastname.value;
s_address = form.s_address.value;
s_address_2 = form.s_address_2.value;
s_city = form.s_city.value;
s_state = form.s_state.value;
_s_state = document.getElementById('_s_state').value;
s_country = form.s_country.value;
s_zipcode = form.s_zipcode.value;
}

function copybilling(form){
if (form.copyb.checked){
InitSaveVariables_shipping(form);
form.s_firstname.value = form.firstname.value;
form.s_lastname.value = form.lastname.value;
form.s_address.value = form.b_address.value;
form.s_address_2.value = form.b_address_2.value;
form.s_city.value = form.b_city.value;
form.s_country.value = form.b_country.value;
form.s_zipcode.value = form.b_zipcode.value;
change_states(document.getElementById('s_country') , 's_state', 'State/Province', '', '', '', '');
form.s_state.value = form.b_state.value;
document.getElementById('_s_state').value = document.getElementById('_b_state').value;
}

else {
form.s_firstname.value = "";
form.s_lastname.value = "";
form.s_address.value = "";
form.s_address_2.value = "";
form.s_city.value = "";
form.s_country.value = form.b_country.value;
form.s_zipcode.value = "";
change_states(document.getElementById('s_country') , 's_state', 'State/Province', '', '', '', '');
form.s_state.value = form.b_state.value;
document.getElementById('_s_state').value = "";
}
}

4) Open common_js.tpl
Add this function

function populateProfile() {
document.registerform.s_firstname.value = document.registerform.firstname.value;
document.registerform.s_lastname.value = document.registerform.lastname.value;
document.registerform.b_firstname.value = document.registerform.firstname.value;
document.registerform.b_lastname.value = document.registerform.lastname.value
}

5)in skin1/customer/home.tpl

after

Code:
<link rel="stylesheet" href="{$SkinDir}/{#CSSFile#}">


add this code

Code:
<script language=JavaScript1.3 src="{$SkinDir}/copybilling.js"></script>


Have basically taken work done by these people and put it all together in something that works for me; hopefully someone else can make use of it...

Credits:

Bob: bobcc99
http://forum.x-cart.com/viewtopic.php?t=17146&highlight=profile

PhilJ

CC

Bradc

epic 10-26-2005 02:59 PM

Worked great!! Thanks :D

elviselviselvis 11-02-2005 06:55 PM

pauldodman

Thanks for summarizing and posting your very helpful method for trimming down the number of times a customer has to enter their name etc.
I did have trouble keeping the First and Last name manditory as it appears something fails to be filled and i get an error message that not all fields are filled when clicking submit button.
www.winterdrive.com

Cheers!

Sam

pauldodman 11-03-2005 01:33 AM

Hi,

It seems you also have a javascript error on the page.

As you don't have all the sections on the page, ie the first section is missing, it is possible that by removing it from the template, you are only removing the display but not the checking that everything has been filled in. So you are possibly checking for fields that although not displayed are still there. Would need to check your code to be sure, but there seem to be a few errors with what you have done.

fitster 11-04-2005 12:05 PM

Nice job with putting it all in one place. One minor thing, It doesn't show the shipping name at order confirmation (last screen where you submit). It does show up on the receipt, but it might be disconcerting to the customer if they are shipping to someone else and the name doesn't show up before they finish the order. :?

pauldodman 11-04-2005 12:22 PM

OK, well it is late here now, so I will have a look when I get chance and let you know how to solve that.

pauldodman 11-07-2005 11:33 AM

Hi Dave,

Firstly, had a look at some of my sites with this mod on and they seem to be carrying the shipping info forward OK.

However, was going to look at your site, but I couldn't get it to go to any of the products. Tried a few links, well I can't say it took a long time, cos I couldn't get any to go - it is still doing one now and I'm on broadband.

Moving back to the original question, what payment methods are you using?

Will have another look at your site tomorrow. Otherwise send me a PM or email to let me know if there is a problem and I'll wait till it is working - or let me know if you need some help with it.

(Just tried again - still no go)

Phlash 02-24-2006 08:05 AM

county
 
I'm new to X-Cart, but have been reading forums - and trying to learn everything I can.
I find this mod a LOT more user-friendly, than the standard checkout.

However, I NEED info on how to make it copy the COUNTY over, as well.

This is due to my state (FL) having about 5 different tax rates, determined by their 'ship-to' county.

Can anyone advise/update this code, and explain how I can do this?

This is what I tried (but it doesn't work):
---------------------------------

function InitSaveVariables_shipping(form){
s_firstname = form.s_firstname.value;
s_lastname = form.s_lastname.value;
s_address = form.s_address.value;
s_address_2 = form.s_address_2.value;
s_city = form.s_city.value;
s_county = form.s_county.value;
s_state = form.s_state.value;
_s_state = document.getElementById('_s_state').value;
s_country = form.s_country.value;
s_zipcode = form.s_zipcode.value;
}

function copybilling(form){
if (form.copyb.checked){
InitSaveVariables_shipping(form);
form.s_firstname.value = form.firstname.value;
form.s_lastname.value = form.lastname.value;
form.s_address.value = form.b_address.value;
form.s_address_2.value = form.b_address_2.value;
form.s_city.value = form.b_city.value;
form.s_county.value = form.b_county.value;
form.s_country.value = form.b_country.value;
form.s_zipcode.value = form.b_zipcode.value;
change_states(document.getElementById('s_country') , 's_state', 'State/Province', '', '', '', '');
form.s_state.value = form.b_state.value;
document.getElementById('_s_state').value = document.getElementById('_b_state').value;
}

else {
form.s_firstname.value = "";
form.s_lastname.value = "";
form.s_address.value = "";
form.s_address_2.value = "";
form.s_city.value = "";
form.s_county.value ="";
form.s_country.value = form.b_country.value;
form.s_zipcode.value = "";
change_states(document.getElementById('s_country') , 's_state', 'State/Province', '', '', '', '');
form.s_state.value = form.b_state.value;
document.getElementById('_s_state').value = "";
}
}

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

I assume either I have the wrong value, OR I need to do something within the 'change' areas?

Also, (while on the County subject) I'd also like to swap the county/state to state/county on the checkout, as well.
Therefore a customer wouldn't have to back-track to enter their county, above the state.
I read that this is done in "register_billing_address.tpl", AND "register_shipping_address.tpl" - but ain't smart enough to figure that out, either... ;)

Please HELP - as I would like to get my current site switched over to X-Cart soon.

Thanks in advance,
Gordon

pauldodman 02-24-2006 08:38 AM

Hi, I am not 100% familiar with US addresses, but I thought that you either had state OR county in the address. By default you would have state in the US, and county in the UK. So I guess you must have added county somehow - perhaps turning it on through the User Profiles Option?

Phlash 02-24-2006 08:52 AM

Yes, I turned it on 'county' - only for taxing reasons.
They have nothing to do with our addresses.
For example, if a customer buys the item in 'county A' - but wants it shipped to 'county B' - I have to charge the 'county B' tax rate.

I just need to collect the county from the customer, with the rest of their info - for tax calculation only.
All of my taxes are set up, and appear to work fine. - So taxes, or addresses aren't the issue.

The problem I'm facing is that this particular mod won't pass the county field into the ship-to-address, when the box is checked. - thus, not being able to complete the sale - untill the customer changes it manually.

It should be a simple fix, but - as I said, I'm probably too stupid... ;)

Thanks,
Gordon

pauldodman 02-24-2006 09:01 AM

Just noticing that you are using v 11, although the mod was put together for 13, it should still work. Are you planning on upgrading to 17 at all? 11 was full of bugs and 17 has improved this feature anyway, you don't need to fill it in - just leave it blank.

If you are going to do this, then you would save time trying to solve this.

Phlash 02-24-2006 09:09 AM

I am using 17...
Sorry.
I thought I changed it in my profile before posting this question.
I guess it didn't stick.

I know you can leave the ship-to blank - but though this 'check box' mod would make it look better....

pauldodman 02-24-2006 09:19 AM

It's kind of redundant in 17, you don't want people to have more clicks - less is best, gets them to the end quicker and then you get paid! No point adding things just to make it look cool - you have to think of the overall goal.

It's up to you though, if you want to try and solve it we can.

Phlash 03-05-2006 06:46 AM

OK.. you've talked me out of it... I did use part of the mod to copy the name down though.

I'd still like to figure out how to have it ask for the county AFTER the state in the checkout though...
It looks kinda funny asking for it before....

Anyone done this yet?

Thanks

ccakins 04-06-2006 11:51 AM

I was able to switch around the State and County order, but am still working on how to get the county field to show only when there are counties configured for that state.

So here's what you have to do. Go into /main/register_billing_address.tpl and find this code:
Code:

{if $default_fields.b_county.avail eq 'Y' and $config.General.use_counties eq "Y"}
<TR>
<TD align="right">{$lng.lbl_county}</TD>
<TD>{if $default_fields.b_county.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
{include file="main/counties.tpl" counties=$counties name="b_county" default=$userinfo.b_county country_name="b_country"}
{if ($reg_error ne "" and $userinfo.b_county eq "" and $default_fields.b_county.required eq 'Y') or $error eq "b_county"}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}


Move it so it's underneath the state block of code:
Code:

{if $default_fields.b_state.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_state}</TD>
<TD>{if $default_fields.b_state.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
{include file="main/states.tpl" states=$states name="b_state" default=$userinfo.b_state default_country=$userinfo.b_country country_name="b_country"}
{if $error eq "b_statecode" and $default_fields.b_state.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}


Do the same thing for /main/register_shipping_address.tpl.

Phlash 04-07-2006 06:14 AM

Thanks, but that didn't work for me....
Is there anywhere else that we need to change the County/State order, to make this work?

My site looks rather confusing to the customer on the checkout page.
I WISH I could fix it...

Any other ideas?
BTW, your plan on making the County field only show up for states with county assigned sounds REAL good!
Let me know if you get that working...

Thanks
Gordon

ccakins 04-07-2006 08:46 AM

I'm trying to remember what exactly I did to make that change. I believe that was it. Make sure you're moving the code to the correct spot because there's 2 "blocks" of code for the state. You should be moving the county code under this line:

Code:

{if ($reg_error ne "" and $userinfo.s_state eq "" and $default_fields.s_state.required eq 'Y') or $error eq "s_statecode"}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}


Ah, just found this one. Check out /main/register_states.tpl.

ajj 04-09-2006 06:57 PM

Re: register form in checkout mode - summary
 
Quote:

Originally Posted by pauldodman
There are a lot of threads regarding entering names 3 times in the checkout register form. The main one has over 3500 views and 6 pages of discussion. If like me you find this confusing and you need a fix for standard 4.0.13 that covers most requirements, then hopefully this will help. (If you are an administrator and I have started a new topic when I shouldn't, sorry, just trying to make a complicated problem to solve via the forum simpler.)

The main thread (http://forum.x-cart.com/viewtopic.php?t=17146&highlight=profile) branches off to solve the problem for version 3, then for Jon's EzCheckout, making it hard to follow and implement a standard fix.

This post:
  • Saves your customer typing in names more than once in the checkout register form.
    still allows them to enter different names if they want to for Billing and Shipping
    Designed for standard 4.0.13
    Makes changes to the register form in checkout.
    Accounts for fact there are 2 register forms, therefore preserves normal register/create profile form


When customer starts the form, enters First and last name; these are duplicated to Billing Address (but not to Shipping)
Fills in the rest of Billing Address. Click the check box to duplicate name and address to Shipping.
Includes County/State and Country.

Doesn't matter if fields are mandatory, as they will get filled in one way or the other, but doesn't remove them as they may well be needed......



Hi,
i think the way you solve this problem is a bit complicate.
Why not just do this.
1. open include/register.php

find

Code:

if ($action == 'cart') {
               
                                if (empty($s_firstname) && $default_fields['firstname']['avail'] == 'Y') {
                                        $HTTP_POST_VARS["s_firstname"] = $s_firstname = $firstname;
                                }
                            if (empty($s_lastname) && $default_fields['lastname']['avail'] == 'Y') {
                                        $HTTP_POST_VARS["s_lastname"] = $s_lastname = $lastname;
                                }

after just add
Code:

if (empty($b_firstname) && $default_fields['firstname']['avail'] == 'Y') {
                                        $HTTP_POST_VARS["b_firstname"] = $b_firstname = $firstname;
                                }
                            if (empty($b_lastname) && $default_fields['lastname']['avail'] == 'Y') {
                                        $HTTP_POST_VARS["b_lastname"] = $b_lastname = $lastname;
                                }
                                if (empty($b_title) && $default_fields['title']['avail'] == 'Y') {
                                        $HTTP_POST_VARS["b_title"] = $b_title = $title;
                                }


2. open skin1/main/register_billing_address.tpl

find
Code:

{if $default_fields.title.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_title}</TD>
<TD>{if $default_fields.title.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<SELECT name="b_title">
{section name=title loop=$name_titles}
<OPTION {if $userinfo.b_title eq $name_titles[title]}selected{/if}>{$name_titles[title]}</OPTION>
{/section}
</SELECT>
</TD>
</TR>
{/if}

{if $default_fields.firstname.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_first_name}</TD>
<TD>{if $default_fields.firstname.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<INPUT type="text" name="b_firstname" size="32" maxlength="32" value="{$userinfo.b_firstname}">
{if $reg_error ne "" and $userinfo.b_firstname eq "" && $default_fields.firstname.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}

{if $default_fields.lastname.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_last_name}</TD>
<TD>{if $default_fields.lastname.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<INPUT type="text" name="b_lastname" size="32" maxlength="32" value="{$userinfo.b_lastname}">
{if $reg_error ne "" and $userinfo.b_lastname eq "" && $default_fields.lastname.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}


replace with
Code:

<INPUT type="hidden" name="b_title" value="{$name_titles[title]}">
<INPUT type="hidden" name="b_firstname" value="{$userinfo.b_firstname}">
<INPUT type="hidden" name="b_lastname" value="{$userinfo.b_lastname}">


done...

TA 06-03-2006 11:55 AM

Thanks for sharing this code ajj!

Has anybody tried this and are there any other issues?

summit 06-28-2006 07:16 AM

the code works up to the point where you hit the "Submit" button, at which point it give me errors about required fields....

any fix for this?

achintya 04-01-2007 12:37 AM

Re: register form in checkout mode - summary
 
HI

Am I correct in thinking that version 4.1.6 takes care of all this now? I have just installed it and it seems that the name etc is only asked for once, with a button to use a different shipping address.


achintya

X-Cart Gold

colonial123 04-10-2007 10:32 AM

Re: register form in checkout mode - summary
 
Did anyone figure out how to copy the county field?

stevep 03-04-2008 09:12 AM

Re: register form in checkout mode - summary
 
nice one paul works a treat.


All times are GMT -8. The time now is 11:54 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.