Page 1 of 1

[SOLVED] Orders - problem editing template

Posted: Wed Mar 11, 2009 8:09 am
by bob_basli
Hi all,

since I'm not living in the US, I wanted to remove the state-field removed from my template.
So what I did is simple remove all the state-filed references from the Billing template, Order confirm template, customer email and amin email.
When placing an order and filling out the newly created form, after clicking on next following error appears:
The following field is invalid: --Add Me - module:Orders string:state--
Dunno what to do since I can't find anything on the required fields.
What to do next?

Regards,
Arjan

ps: also would like to set the default country to Netherlands instead of US.
How do I do That?

Re: Orders - problem editing template

Posted: Tue Mar 17, 2009 12:35 pm
by bob_basli
Hi alle,
does anyone have an idea on this one or am I the only one who wants to change the required fieds?

Hope to hear from ya soon!
Regards,

Re: Orders - problem editing template

Posted: Sun Jul 05, 2009 3:17 am
by kurashiki_ben
bob_basli wrote: Hi all,

since I'm not living in the US, I wanted to remove the state-field removed from my template.
So what I did is simple remove all the state-filed references from the Billing template, Order confirm template, customer email and amin email.
When placing an order and filling out the newly created form, after clicking on next following error appears:
The following field is invalid: --Add Me - module:Orders string:state--
Dunno what to do since I can't find anything on the required fields.
What to do next?

Regards,
Arjan
Hi Arjan

Try editing the Orders.module.php file

find the following:
function validate_billing_info(&$billing,&$field)

and then comment out the billing state validation like this:

//  if( !isset($billing['state']) || empty($billing['state']) )
//      {
// $field = 'state';
// return false;
//      }

(that way you can put it back later if you ever need it)
ps: also would like to set the default country to Netherlands instead of US.
How do I do That?
I am trying to do this now myself.
I'll let you know if I come up with a solution.

Regards

Ben

Re: Orders - problem editing template

Posted: Tue Aug 11, 2009 1:48 pm
by jennifer-rose
Hi Arjan
Hi all,

since I'm not living in the US, I wanted to remove the state-field removed from my template.
So what I did is simple remove all the state-filed references from the Billing template, Order confirm template, customer email and amin email.
When placing an order and filling out the newly created form, after clicking on next following error appears:

Quote
The following field is invalid: --Add Me - module:Orders string:state--

Dunno what to do since I can't find anything on the required fields.
What to do next?

Regards,
Arjan
No need to remove {$mod->Lang('state/province')}:* {$input_billing_state}

use {* *}

{*{$mod->Lang('state/province')}:* {$input_billing_state}
*}

then this underneath from Ben purrrrrrrfect
Hi Arjan

Try editing the Orders.module.php file

find the following:
function validate_billing_info(&$billing,&$field)

and then comment out the billing state validation like this:

//  if( !isset($billing['state']) || empty($billing['state']) )
//      {
//  $field = 'state';
//  return false;
//      }

(that way you can put it back later if you ever need it)
Jenn

Re: [SOLVED] Orders - problem editing template

Posted: Wed Aug 12, 2009 1:57 pm
by kurashiki_ben
bob_basli wrote:
ps: also would like to set the default country to Netherlands instead of US.
How do I do That?
I think I found it.

Within the orders module files, open action.default.php

Then find the following around line 750:

Code: Select all

$smarty->assign_by_ref('mod',$this);
if( !empty($status) )
  {
    $smarty->assign('status',$status);
    $smarty->assign('message',$message);
  }
$smarty->assign('formstart',$this->CGCreateFormStart($id, 'default', $returnid, $params));
$smarty->assign('formend',$this->CreateFormEnd());

$smarty->assign('input_billing_first_name', 
		$this->CreateInputText($id, 'billing_first_name', 
				       $billing['first_name'], 30));
$smarty->assign('input_billing_last_name', 
		$this->CreateInputText($id, 'billing_last_name', 
				       $billing['last_name'], 30));
$smarty->assign('input_billing_address1', 
		$this->CreateInputText($id, 'billing_address1', 
				       $billing['address1'], 50));
$smarty->assign('input_billing_address2', $this->CreateInputText($id, 'billing_address2', 
							   $billing['address2'], 50));
$smarty->assign('input_billing_city', $this->CreateInputText($id, 'billing_city', 
						       $billing['city'], 30));
$smarty->assign('input_billing_state', 
		$this->CreateInputStateDropdown($id, 'billing_state', 
			 $billing['state'] != '' ? $billing['state'] : 'AL', false));
$smarty->assign('input_billing_postal', 
		$this->CreateInputText($id, 'billing_postal', $billing['postal'], 20));
$smarty->assign('input_billing_country', 
		$this->CreateInputCountryDropdown($id, 'billing_country', 
			  $billing['country'] != '' ? $billing['country'] : 'US', false));
$smarty->assign('input_billing_phone', 
		$this->CreateInputText($id, 'billing_phone', $billing['phone'], 30));
$smarty->assign('input_billing_fax', 
		$this->CreateInputText($id, 'billing_fax', $billing['fax'], 30));
$smarty->assign('input_billing_email', 
		$this->CreateInputText($id, 'billing_email', $billing['email'], 80));
Go to:

Code: Select all

	$this->CreateInputCountryDropdown($id, 'billing_country', 
			  $billing['country'] != '' ? $billing['country'] : 'US', false));
Change the 'US' part to the code for your country.
E.g. NL for the Netherlands, GB for the United Kingdom.

These codes can be found within the CGExtensions module files, in countries.txt
Incidentally, the functions used to make the countries and states lists can all be found in the CGExtensions module, in the files form_tools.php and CGExtensions.module.php

Regards

Ben

P.s., I found that the length of the email field (80), breaks the page, so you can also easily change 80 at the end of the line:

Code: Select all

$this->CreateInputText($id, 'billing_email', $billing['email'], 80));
to a smaller value.

Re: [SOLVED] Orders - problem editing template

Posted: Sun Aug 23, 2009 3:27 am
by psy
Another suggestion... simply modify the Billing template as follows:

Code: Select all

<span class="required" style="display:none">{$mod->Lang('state/province')}:* {$input_billing_state}<br /></span>
You'll also have to edit the other templates to ensure it doesn't print out the default state.

This way the field is removed from the (visible) template output while maintaining module integrity so it wont break on upgrades.

hth
psy

Re: [SOLVED] Orders - problem editing template

Posted: Fri Oct 02, 2009 8:59 am
by SideshowBob
I used this little bit of jQuery to set the default country, seems better than hacking the php files.

Make sure you load the jQuery library first and the insert this code

Code: Select all

{literal}
<__script__ type="text/javascript">
$(function() {
     field_name = 'ma5380billing_country';
     default_value = 'GB';
     $("select[name='"+field_name+"'] option[value='"+default_value+"']").attr('selected', true);
});
</__script>
{/literal}
Obviously adjust field_name & default_value to suit your needs.

Hope that helps,
Bob