Jump to content


Corporate Sponsors


Latest News: (loading..)

redrum

Member Since 28 Oct 2003
Offline Last Active Today, 08:11
-----

Posts I've Made

In Topic: [Contribution] Upgrading osC from 2.2 MS2 to 2.2 RC2a

Yesterday, 18:48

I have a custom made one-page-checkout (namned checkout.php). In the country pull down menu I used to have Sweden as pre-selected.
That pre-selection was disapeared after the upgrade to rc2a. This is due to the new function tep_draw_pull_down_menu in includes/functions/html_output.php

So if I use the rc2a:
  function tep_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) {
	global $HTTP_GET_VARS, $HTTP_POST_VARS;
	$field = '<select name="' . tep_output_string($name) . '"';
	if (tep_not_null($parameters)) $field .= ' ' . $parameters;
	$field .= '>';
	if (empty($default) && ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) ) {
	  if (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) {
		$default = stripslashes($HTTP_GET_VARS[$name]);
	  } elseif (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) {
		$default = stripslashes($HTTP_POST_VARS[$name]);
	  }
	}
	for ($i=0, $n=sizeof($values); $i<$n; $i++) {
	  $field .= '<option value="' . tep_output_string($values[$i]['id']) . '"';
	  if ($default == $values[$i]['id']) {
		$field .= ' SELECTED';
	  }
	  $field .= '>' . tep_output_string($values[$i]['text'], array('"' => '&quot;', '\'' => '&#039;', '<' => '&lt;', '>' => '&gt;')) . '</option>';
	}
	$field .= '</select>';
	if ($required == true) $field .= TEXT_FIELD_REQUIRED;
	return $field;
  }
no country is pre-selected.

If I use the old ms2:
  function tep_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) {
	$field = '<select name="' . tep_output_string($name) . '"';
	if (tep_not_null($parameters)) $field .= ' ' . $parameters;
	$field .= '>';
	if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes($GLOBALS[$name]);
	for ($i=0, $n=sizeof($values); $i<$n; $i++) {
	  $field .= '<option value="' . tep_output_string($values[$i]['id']) . '"';
	  if ($default == $values[$i]['id']) {
		$field .= ' SELECTED';
	  }
	  $field .= '>' . tep_output_string($values[$i]['text'], array('"' => '&quot;', '\'' => '&#039;', '<' => '&lt;', '>' => '&gt;')) . '</option>';
	}
	$field .= '</select>';
	if ($required == true) $field .= TEXT_FIELD_REQUIRED;
	return $field;
  }
the store country is pre-selected just as it should.

This is how my code for selecting country looks like:
<?php echo tep_get_country_list('country', ($HTTP_POST_VARS['country'] ? $HTTP_POST_VARS['country'] : $order->billing['country']['id']),'onchange="sb=1;copy_shipping(document.getElementsByName(\'ship_as_bill\')[0],true);sb=0;getbillstatewithshipp();" class="checkoutCountry" style="width:145px;"') . '&nbsp;' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?>

Should I stick to the old ms2 function tep_draw_pull_down_menu?
Or can anyone help me out modify the code for selecting country in my checkout.php?


Thanks,
Fredrik

In Topic: Different pre-selected address in checkout process

24 December 2011, 08:20

Thanks for your reply geoffreywalton.

I thougt I did that in a working way when I changed
$billto = $customer_default_address_id;
to
$billto != $customer_default_address_id;
so $billto is not equal to $customer_default_address_id

Do you have any more pointers that might put me in the right direction?

Cheers,
// Fredrik