Jump to content
Muscator

Customize fields on order

Recommended Posts

I am new to cubebart and I struggle to remove a field on the order form.

 

In my country, we do not use 'state/county' in any way, so having this field set as 'required' per default is annoying.

 

I have tried to remove the filed by editing in the '/orders.index.php' and the '/orders.print.php' but it keeps being on the order form?

 

Trying to clear cache also din´t change anything....

 

How to get rid of it?

 

I also need to find out how a field is changed from 'required' to 'non-required' on the order form, eg. the field phone and mobile - in my country only few people have a landline based phone anymore, therefore it seems a bit weired to the customers that a landline filed is required to fill out - you might say that they can just put their mobile number in the landline field, yes - but still it is annoying that the field is required

Actually it would be nice if it was possible to edit the order form completely to make it comply to local settings - many carts has this option built in....

 

How to change that?

 

Any assistance is highly appreciated

Share this post


Link to post
Share on other sites

I changed the wording to Best Phone number, and then at the bottom of the file commented out the line that requires validation for the other phone number. If you never need the other phone choice line you could comment it out.

I don't remember if Bsmither had to help with a code change in the JavaScript file or something similar to stop requiring the validation of the extra or hidden phone number.

Such edits will not survive an upgrade and would need to be added back in manually each time.

Share this post


Link to post
Share on other sites

Thanks for the imput...

Yes, as You write any change will have to be revised every time there is an update and that is exactly why I suggest that there in future versions will be an option to edit any field at all concerning the order form as this is really a place for customization and that way it will remain the same even after an upgrade...

Thanks for the 'comment out' idea - I have had the same thought but I unfortunately fail to see which file I have to make the changes in as none of the files I have found concerning the orderform seems to have both phone lines and the files where I have changed/removed the unwanted 'state/county' field had absolutely no effect at all - even not after clearing the cache as suggested by Bsmither...

 

So - remaing challenges are:

1. Removal of 'state/county'field permanently

2. Removal of unwanted phone field

3. Adding field 'address' in the form option in the top' Sign-up'

 

Input will be much appreciated ;-)

Share this post


Link to post
Share on other sites

I'm on my Kindle and not on the computer, so I can't give specifics. If you want to suggest this be editable from admin you should make the suggestion on the Feature Request board... link in my signature.

Edited by Dirty Butter

Share this post


Link to post
Share on other sites

Hmnn,

 

I have now finally found the correct files to edit (templates/content.checkout.confirm.php), but when editing them and commenting state/county out, I end up with the form claiming that 'billing address missing'...?

Also - when editing 'content.register.php' and adding address field, this address is not added for some reason...?

Any ideas?

Edited by Muscator

Share this post


Link to post
Share on other sites

There's somewhere I think in the skin javascript file that needs changing that controls validation. Bsmither will know what to do.

Share this post


Link to post
Share on other sites

Investigating further I have found that I can comment out the 'phone' field without any problems, but when commenting out 'state/county and/or 'country' new problems arise, as there seems to be a hook to somewhere else as that commenting out results in the above error with 'billing address missing'...?

 

So - kinda 'Cacth22' error - for a novice in programming this is really complicated, whereas it probably is 'common knowledge' for many others - for me however it is extremely difficult to look through all the programming to see what I have to do....

Therefore - any input much appriciated....

Share this post


Link to post
Share on other sites

I really would appreciate if eg. bsmither would have a look at this topic and contribute with an idea to how I get rid of the 'county/state' box in the order form.....?

 

Thanks

Share this post


Link to post
Share on other sites

I see three edits for the Foundation skin:
1. content.checkout.confirm.php
2. 3.cubecart.validate.js
3. /classes/cubecart.class.php

content.checkout.confirm.php

Find:
<div class="small-12 large-8 columns"><label for="user_phone" class="show-for-medium-up">{$LANG.address.phone}</label><input type="text" name="user[phone]" id="user_phone" required value="{$USER.phone}" placeholder="{$LANG.address.phone}  {$LANG.form.required}" autocomplete="tel"></div>

Change to:
<div class="small-12 large-8 columns"><label for="user_phone" class="show-for-medium-up">{$LANG.address.phone}</label><input type="text" name="user[phone]" id="user_phone" value="{$USER.phone}" placeholder="{$LANG.address.phone}" autocomplete="tel"></div>

Find:
      <div class="row">
         <div class="small-12 large-8 columns"><label for="state-list" class="show-for-medium-up">{$LANG.address.state}</label><input type="text" name="billing[state]" id="state-list"  required value="{$BILLING.state}" autocomplete="address-line1"></div>
      </div>

Change to:
{*
      <div class="row">
         <div class="small-12 large-8 columns"><label for="state-list" class="show-for-medium-up">{$LANG.address.state}</label><input type="text" name="billing[state]" id="state-list"  required value="{$BILLING.state}" autocomplete="address-line1"></div>
      </div>
*}

Find:
      <div class="row">
         <div class="small-12 large-8 columns"><label for="delivery_state" class="show-for-medium-up">{$LANG.address.state}</label><input type="text" name="delivery[state]" id="delivery_state"  required value="{$DELIVERY.state}" placeholder="{$LANG.address.state} {$LANG.form.required}" autocomplete="address-level1"></div>
      </div>
   </address>
</div>
{/if}
<script type="text/javascript">
   var county_list = {$STATE_JSON};
</script>

Change to:
{*
      <div class="row">
         <div class="small-12 large-8 columns"><label for="delivery_state" class="show-for-medium-up">{$LANG.address.state}</label><input type="text" name="delivery[state]" id="delivery_state"  required value="{$DELIVERY.state}" placeholder="{$LANG.address.state} {$LANG.form.required}" autocomplete="address-level1"></div>
      </div>
*}
   </address>
</div>
{/if}
{*
<script type="text/javascript">
   var county_list = {$STATE_JSON};
</script>
*}
3.cubecart.validate.js

Find:
            'billing[state]': {
                required: true
            },

Change to:
/*
            'billing[state]': {
                required: true
            },
*/

Find:
            'delivery[state]': {
                required: true
            },

Change to:
/*
            'delivery[state]': {
                required: true
            },
*/
cubecart.class.php, near line 947:

From:
$required_address_fields = array('first_name','last_name','line1','town','country','state','postcode');

To:
$required_address_fields = array('first_name','last_name','line1','town','country',/*'state',*/'postcode');

This is for that case where the customer has not logged in, and is checking out. CubeCart may use the store's address as a temporary billing and delivery address until the customer provides their own. Thus, after entering this info in the "Profile" (Customer Details) section of the checkout screens, the customer may be given this screen again with a note that details have been updated and shipping charges may have changed - if appropriate.

These changes may also cover the case where the customer is logged in. I haven't tried that.

And there is the situation where the Addressbook may also demand a State/County. We can work on that if you get stuck.

 

Share this post


Link to post
Share on other sites

Thanks bsmither for the valuable input and your time on this topic,

 

It seems as if the problem is solved - I will test again and report back asap

Share this post


Link to post
Share on other sites

It appears that this fix is only for this specific situation. Should a customer wish to ship to someone outside of this cart location, or Muscator decide to sell to someone located in a country that does have states or provinces, he will find that this fix will not allow that customer to properly fill out the forms.

 

Share this post


Link to post
Share on other sites

Geotex is right in pointing this out, but I actually asked for exactly this solution and that is exactly what I got.

 

The good thing is, that if I suddenly decide to sell to countries with states, I just reverse what bsmither recommended and I will have states back as an option - so anyone can use it and anyone can reverse it if needed at any time...

Edited by Muscator

Share this post


Link to post
Share on other sites

bsmither,

 

 

as you forecasted, some problems arose...

 

When logged in as a customer and trying to checkout, the following error occurs:

 

" We seem to have a problem with your address ("Standard faktureringsadresse"). Please check the value for "County" before proceeding."

Furthermore the client can´t delete items in the cart when logged in.

Any attempt to change anything when logged in results in the above error.

Share this post


Link to post
Share on other sites

I see a problem in the logic where this test is being made. The logic imposes that, if there is a 'country, there must be a 'state'.

Until I formulate a better logic solution, try this (haven't tried it myself):

/classes/user.class.php, near line 457,

Find this really long line, only the beginning is shown:

if($user_defined && !CC_IN_ADMIN

Add the new code to the existing line as shown:

if(!($GLOBALS['config']->get('config', 'disable_estimates')=='1') && $user_defined && !CC_IN_ADMIN

Then, in admin, Store Settings, Features tab, for "Disable initial shipping & tax estimates", check that box.

Share this post


Link to post
Share on other sites

The error here is in the interpretation of the logic. All countries that have "state" have the states listed and tied to their country code in table CubeCart_geo_zones. If the country does not have states, there is no listing. The current coding will provide a drop down if states exist, no drop down if states do not. exist. The issue comes with Submit, as the field states is required, and the ajax validation script does not recognize that the state is no longer required.

The excellent patch you provided Muscator works and can be applied to table CubeCart_addressbook. That should clear Muscator's problem, and I am sure he can find the lines.

I would suggest the issue is best resolved by also having "required" removed from the state input when the country code is not present in CubeCart_geo_zones. Currently, the only change is to not create the drop down state option, it does not remove the "required" statement that causes the error in  skins/[your template]/js/vendor/jquery.validate.min.js.

I have not had time to fully investigate, but that the only logical place to properly correct the issue is at the form level, and each form that requires a state/county input needs to be dealt with. This is a bug that, if not submitted already, should be as it is an extremely aggravating issue in the many, many countries that do not have states or similar regional districts and is a wide-reaching problem covering both registered and non-registered purchasers, as well as all addresses in the CubeCart_addressbook table and possibly a few others.

Share this post


Link to post
Share on other sites

bsmither,geotex,

 

Thanks for your valuable input.

 

I have tried applying

 

"if(!($GLOBALS['config']->get('config', 'disable_estimates')=='1')
            && $user_defined &&
            !CC_IN_ADMIN"

 

to the END of the very long line starting in line 457 after 'false;'

 

This results in a 500 error, so I am probably applyning it wrongly as Geotex apparently has tested it and found no problems...?

 

Any particular way it should be added if not directly after 'false;'? (please excuse my novice questions)

 

Here is the code I have tried:

 

"

// Check state
        $country_id = getCountryFormat($address['country'], 'numcode', 'id');
        if(!($GLOBALS['config']->get('config', 'disable_estimates')=='1') $user_defined && !CC_IN_ADMIN && $_GET['_a']!=='addressbook' && ((empty($address['state']) && !empty($address['country'])) || ($GLOBALS['db']->select('CubeCart_geo_zone',false, array($state_field => $address['state']))==false) && $GLOBALS['db']->select('CubeCart_geo_zone',false, array('country_id' => $country_id)))) {
            $address_description = empty($address['description']) ? '' : ' (&quot;'.$address['description'].'&quot;)';
            $GLOBALS['gui']->setError(sprintf($GLOBALS['language']->address['check_state'],$address_description));
            httpredir("?_a=addressbook&action=edit&address_id=".$address['address_id']);
            return false;
        }


"

"

// Check state
        $country_id = getCountryFormat($address['country'], 'numcode', 'id');
        if($user_defined && !CC_IN_ADMIN && $_GET['_a']!=='addressbook' && ((empty($address['state']) && !empty($address['country'])) || ($GLOBALS['db']->select('CubeCart_geo_zone',false, array($state_field => $address['state']))==false) && $GLOBALS['db']->select('CubeCart_geo_zone',false, array('country_id' => $country_id)))) {
            $address_description = empty($address['description']) ? '' : ' (&quot;'.$address['description'].'&quot;)';
            $GLOBALS['gui']->setError(sprintf($GLOBALS['language']->address['check_state'],$address_description));
            httpredir("?_a=addressbook&action=edit&address_id=".$address['address_id']);
            return false;
          if(!($GLOBALS['config']->get('config', 'disable_estimates')=='1')
          && $user_defined &&
          !CC_IN_ADMIN

"

 

 

Edited by Muscator
more info

Share this post


Link to post
Share on other sites
Find this really long line, only the beginning of it is shown below.

if($user_defined && !CC_IN_ADMIN

REPLACE JUST THIS PART of that long line:

if($user_defined && !CC_IN_ADMIN

WITH THIS:

if(!($GLOBALS['config']->get('config', 'disable_estimates')=='1') && $user_defined && !CC_IN_ADMIN


Here is the whole complete line:

if($user_defined && !CC_IN_ADMIN && $_GET['_a']!=='addressbook' && ((empty($address['state']) && !empty($address['country'])) || ($GLOBALS['db']->select('CubeCart_geo_zone',false, array($state_field => $address['state']))==false) && $GLOBALS['db']->select('CubeCart_geo_zone',false, array('country_id' => $country_id)))) {

Here is the whole complete line after adding the new code:

if(!($GLOBALS['config']->get('config', 'disable_estimates')=='1') && $user_defined && !CC_IN_ADMIN && $_GET['_a']!=='addressbook' && ((empty($address['state']) && !empty($address['country'])) || ($GLOBALS['db']->select('CubeCart_geo_zone',false, array($state_field => $address['state']))==false) && $GLOBALS['db']->select('CubeCart_geo_zone',false, array('country_id' => $country_id)))) {

 

Share this post


Link to post
Share on other sites

bsmither,

 

Thanks for clarifying code for a non-experienced 'coder'

This did the trick and seems to work correct - I will report if any other issues occur

 

Thanks for invaluable help here.....

 

 

 

Share this post


Link to post
Share on other sites
On 15/08/2017 at 5:29 AM, bsmither said:

I see three edits for the Foundation skin:
1. content.checkout.confirm.php
2. 3.cubecart.validate.js
3. /classes/cubecart.class.php


content.checkout.confirm.php

Find:
<div class="small-12 large-8 columns"><label for="user_phone" class="show-for-medium-up">{$LANG.address.phone}</label><input type="text" name="user[phone]" id="user_phone" required value="{$USER.phone}" placeholder="{$LANG.address.phone}  {$LANG.form.required}" autocomplete="tel"></div>

Change to:
<div class="small-12 large-8 columns"><label for="user_phone" class="show-for-medium-up">{$LANG.address.phone}</label><input type="text" name="user[phone]" id="user_phone" value="{$USER.phone}" placeholder="{$LANG.address.phone}" autocomplete="tel"></div>

Find:
      <div class="row">
         <div class="small-12 large-8 columns"><label for="state-list" class="show-for-medium-up">{$LANG.address.state}</label><input type="text" name="billing[state]" id="state-list"  required value="{$BILLING.state}" autocomplete="address-line1"></div>
      </div>

Change to:
{*
      <div class="row">
         <div class="small-12 large-8 columns"><label for="state-list" class="show-for-medium-up">{$LANG.address.state}</label><input type="text" name="billing[state]" id="state-list"  required value="{$BILLING.state}" autocomplete="address-line1"></div>
      </div>
*}

Find:
      <div class="row">
         <div class="small-12 large-8 columns"><label for="delivery_state" class="show-for-medium-up">{$LANG.address.state}</label><input type="text" name="delivery[state]" id="delivery_state"  required value="{$DELIVERY.state}" placeholder="{$LANG.address.state} {$LANG.form.required}" autocomplete="address-level1"></div>
      </div>
   </address>
</div>
{/if}
<script type="text/javascript">
   var county_list = {$STATE_JSON};
</script>

Change to:
{*
      <div class="row">
         <div class="small-12 large-8 columns"><label for="delivery_state" class="show-for-medium-up">{$LANG.address.state}</label><input type="text" name="delivery[state]" id="delivery_state"  required value="{$DELIVERY.state}" placeholder="{$LANG.address.state} {$LANG.form.required}" autocomplete="address-level1"></div>
      </div>
*}
   </address>
</div>
{/if}
{*
<script type="text/javascript">
   var county_list = {$STATE_JSON};
</script>
*}

3.cubecart.validate.js

Find:
            'billing[state]': {
                required: true
            },

Change to:
/*
            'billing[state]': {
                required: true
            },
*/

Find:
            'delivery[state]': {
                required: true
            },

Change to:
/*
            'delivery[state]': {
                required: true
            },
*/

cubecart.class.php, near line 947:

From:
$required_address_fields = array('first_name','last_name','line1','town','country','state','postcode');

To:
$required_address_fields = array('first_name','last_name','line1','town','country',/*'state',*/'postcode');

This is for that case where the customer has not logged in, and is checking out. CubeCart may use the store's address as a temporary billing and delivery address until the customer provides their own. Thus, after entering this info in the "Profile" (Customer Details) section of the checkout screens, the customer may be given this screen again with a note that details have been updated and shipping charges may have changed - if appropriate.

These changes may also cover the case where the customer is logged in. I haven't tried that.

And there is the situation where the Addressbook may also demand a State/County. We can work on that if you get stuck.

 

Hi,

I've updated to 6.1.12, have made all changes to the files above to disable county. it was working fine with 6.1.10 with those changes. I'm using paypal express checkout and I'm based in UK there are many customers having account set without county now ( this issue has been raised many times here on forums), before I start, called up paypal to make sure that the billing address is set on my paypal account as advised in braintree mod and it is. Tested the express checkout ( via braintree or paypal pro) and I'm always getting an error message asking for a state when transfered back to website from paypal confirmation page.

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

×