Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Active Countries


Guest

Recommended Posts

bah. I'm an idiot. ignore my post. I deleted the post I originally uh... posted.

just ignore this. lol.

 

the contribution works great so far. many thanks to you.

Do you mind if I upload a modified version of the readme? It's just more organized and easier to read... slightly (files are listed alphabetically and steps are highlighted).

Edited by erikwoods
Link to comment
Share on other sites

  • Replies 257
  • Created
  • Last Reply

Top Posters In This Topic

I am not sure this fix is enough. Basically you don't want a redirection to take place when you change the country from the drop-down country list. Maybe the country change check should take place in every else statement in the if section. So its like this now

 

	if( !$error && !$country_flag ) {
.
.
.
} elseif (isset($HTTP_POST_VARS['address'])) {
.
.
.
} else {

 

Should been

	if( !$error && !$country_flag ) {
.
.
.
} elseif (isset($HTTP_POST_VARS['address']) && !$country_flag) {
.
.
.
} elseif(!$country_flag) {

 

That will eliminate the code flow going through the redirection when someone simply changes country.

Link to comment
Share on other sites

If you have more than 1 countries active and the customer changes the country on the billing section (checkout_payment_address.php) and all information is correct it may store the new billing address if the customer changes the country.

 

The problem is I don't know why it will make a difference since an error is in place. You see once you change country the state selector falls back to the "Please Select" so it will always generate an error and so it wont allow to do the redirect. Unless you have modified some other code for the state, I don't think it will make a difference

 

I tried to replicate the problem here but I did not see a problem with or without this fix.

Edited by enigma1
Link to comment
Share on other sites

  • 2 weeks later...

just added this beauty of a mod to another of my test sites and finally realise the potetial of the script.

 

it is in essence the same as country/state selector but with the active countries on/off it makes it very easy to just put that side of things to rest

 

well done and thanks!

Upon receiving fixes and advice, too many people don't bother to post updates informing the forum of how it went. Until of course they need help again on other issues and they come running back!

 

Why receive the information you require in good faith for free, only to then have the attitude to ignore the people who gave it to you?

 

There's no harm in saying, 'Thanks, it worked'. On the contrary, it creates a better atmosphere.

 

CHOOCH

Link to comment
Share on other sites

If you have more than 1 countries active and the customer changes the country on the billing section (checkout_payment_address.php) and all information is correct it may store the new billing address if the customer changes the country.

 

The problem is I don't know why it will make a difference since an error is in place. You see once you change country the state selector falls back to the "Please Select" so it will always generate an error and so it wont allow to do the redirect. Unless you have modified some other code for the state, I don't think it will make a difference

 

I tried to replicate the problem here but I did not see a problem with or without this fix.

 

The problem occur when you have a mix of countries with and without zones , the countries without zones will not not throw a state selector "Please Select" but just redirect on.....

 

To fix , well eighter do a redirect fix....or update your countries so that all the available countries have zones attached.

Edited by toyicebear
Link to comment
Share on other sites

Hello Nick, thanks for the clarification. The contribution code (reference files) include the drop-down list as replacement for the state selectors. I would assume for the countries of interest someone will setup states so taxes, shipping etc. will work properly.

 

Anyways as a precaution I moved the check of the country together with the error

 

So if the state selector changes the flag is asserted bypassing the entry. I believe this should cover all cases. All 4 files should be modified in case no state selectors are set for active countries to check for the country_flag.

 

address_book.php

checkout_payment_address.php

checkout_shipping_address.php

create_account.php

 

catalog\address_book_process.php

	if( !$error && !$country_flag ) {
  $sql_data_array = array('entry_firstname' => $firstname,
						  'entry_lastname' => $lastname,
						  'entry_street_address' => $street_address,
						  'entry_postcode' => $postcode,
						  'entry_city' => $city,
						  'entry_country_id' => (int)$country);

 

checkout_payment_address.php

	  if( !$error && !$country_flag) {
	$sql_data_array = array('customers_id' => $customer_id,
							'entry_firstname' => $firstname,
							'entry_lastname' => $lastname,
							'entry_street_address' => $street_address,
							'entry_postcode' => $postcode,
							'entry_city' => $city,
							'entry_country_id' => $country);

 

checkout_shipping_address.php

	if( !$error && !$country_flag ) {
	$sql_data_array = array('customers_id' => $customer_id,
							'entry_firstname' => $firstname,
							'entry_lastname' => $lastname,
							'entry_street_address' => $street_address,
							'entry_postcode' => $postcode,
							'entry_city' => $city,
							'entry_country_id' => $country);

 

create_account.php

	if( !$error && !$country_flag) {
  $sql_data_array = array('customers_firstname' => $firstname,
						  'customers_lastname' => $lastname,
						  'customers_email_address' => $email_address,
						  'customers_telephone' => $telephone,
						  'customers_fax' => $fax,
						  'customers_newsletter' => $newsletter,
						  'customers_password' => tep_encrypt_password($password));

 

 

In all 4 cases I added in the if statement to check for the $country_flag.

Link to comment
Share on other sites

  • 2 weeks later...

In admin/countries.php... in the readme it says find

<td class="dataTableHeadingContent" align="center" colspan="2"><?php echo TABLE_HEADING_COUNTRY_CODES; ?></td>

and add

<td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_STATUS; ?> </td>

below it...

 

but I think it's supposed to be the other way around. Am I right?

Edited by erikwoods
Link to comment
Share on other sites

the code for the table cells should be:

 

				<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_COUNTRY_NAME; ?></td>
			<td class="dataTableHeadingContent" align="center" colspan="2"><?php echo TABLE_HEADING_COUNTRY_CODES; ?></td>
			<td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_STATUS; ?> </td>
			<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td>

 

so its below as the readme says. Why should be the other way around?

Link to comment
Share on other sites

Because the version of admin/countries.php that I am getting from the latest download of osCommerce does not have the string "TABLE_HEADING_COUNTRY_CODES" in it anywhere at all. But it does have

<td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_STATUS; ?> </td>

in it already.

Link to comment
Share on other sites

what's the file version? The one I have is 1.28 the code from the default osc is this

 

				<td class="dataTableHeadingContent"><?php echo TABLE_HEADING_COUNTRY_NAME; ?></td>
			<td class="dataTableHeadingContent" align="center" colspan="2"><?php echo TABLE_HEADING_COUNTRY_CODES; ?></td>
			<td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td>

 

I don't see the countries status implemented in the default file.

Link to comment
Share on other sites

For includes/modules/address_book_details.php it says find:

<td class="main"><?php echo tep_get_country_list('country') . ' ' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?></td>

 

but in the version I have (from default osCommerce 2.2 ms2), it says

<td class="main"><?php echo tep_get_country_list('country', $entry['entry_country_id']) . ' ' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?></td>

 

What should I put in its place?

 

I didn't know this contribution was for version 1.28 of oscom.

Link to comment
Share on other sites

I don't know why I didn't find this problem the first time I went through adding this contribution.

Do you know if it's safe to just replace it with the same line of code that you said to use in your version?

 

The rest of the files I had no problems with. Just this one. It was this one that I originally meant to post about- that's why I couldn't figure out why my version wasn't different when I looked back at it.

Sorry about the confusion. I've had a late night.

 

So yeah... what's the deal with includes/modules/address_book_details.php?

Link to comment
Share on other sites

Yes that's a missing part to find the original line from the readme

, $entry['entry_country_id']

 

The replacement code has everything and it's ok. So I will update the notes with the next version for the "find" line

Link to comment
Share on other sites

So let me just make sure I understand what you just said.

It is okay to replace

 

<td class="main"><?php echo tep_get_country_list('country', $entry['entry_country_id']) . ' ' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?></td>

 

with

 

<td class="main"><b><?php echo ($tmp_object = tep_get_country_active_list('country', $country, 'onChange="this.form.submit();"')) . tep_draw_hidden_field('country_old', $country) . ' ' . (is_array($tmp_object) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?></b></td>

?

 

Sorry for all the newbie-ness. I just want to make sure that this cart works this time. I'm starting from scratch and I want to include all of the contributions I had in the previous one and see what changes made the taxes go away.

Link to comment
Share on other sites

yes here are the updated instructions:

 

4. Open catalog\includes\modules\address_book_details.php

 

4-1: Locate this line of code

 

<td class="main"><?php echo tep_get_country_list('country', $entry['entry_country_id']) . '?' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?></td>

 

 

 

Replace it with the following line of code

<td class="main"><b><?php echo ($tmp_object = tep_get_country_active_list('country', $country, 'onChange="this.form.submit();"')) . tep_draw_hidden_field('country_old', $country) . ' ' . (is_array($tmp_object) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?></b></td>

Link to comment
Share on other sites

  • 3 months later...

I just installed this contribution, and it seemed to work fine at first. But then I tried creating a new address in checkout_shipping_address.php, and I got this error:

 

1062 - Duplicate entry '0' for key 1

 

insert into address_book (customers_id, entry_firstname, entry_lastname, entry_street_address, entry_postcode, entry_city, entry_country_id, entry_company, entry_zone_id, entry_state) values ('3', 'Tester', 'Testing', 'lsjkgpoui', '65498', 'Acampo', '223', '', '12', '')

 

[TEP STOP]

 

It looks to me like it's just entering the state I enter as the zone_id, and not as the entry state. I'm looking at the checkout_shipping address page, and I'm not quite sure how to fix it. I have fast easy checkout installed, and there's some code there that could be screwing it up, but I already ran my copy of the page through winmerge against the included demo files, and removed the code pertaining to fast easy checkout, but that didn't fix it.

 

Any help would be appreciated.

Always BACK UP your files and your database before making any changes. Before asking questions, check out the Knowledge Base. Check out the contributions to see if your problem's solved there. Search the forums.

 

Useful threads: Store Speed Optimization How to make a horrible shop Basics for design change How to search the forums

 

Useful contributions: Easypopulate Fast, Easy Checkout Header Tag Controller

Link to comment
Share on other sites

sounds like the autoincrement in the address_book table of your database is not working for some reason.

 

here is the source line in that file where the error is generated I think:

		tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array);

 

First check the sql address_book table with phpmyadmin. The address_book_id should be set to auto_increment. Then check what was the last value you had for address_book_id and compare it with the next autoindex value. The next autoindex should be +1 of the highest address_book_id. So tell me what the values are.

 

Can you also post the checkout_shipping_address.php source code that fails?

Link to comment
Share on other sites

Thank you - somehow the address_book_id hadn't been set to auto_increment. I changed that and it solved the problem.

Always BACK UP your files and your database before making any changes. Before asking questions, check out the Knowledge Base. Check out the contributions to see if your problem's solved there. Search the forums.

 

Useful threads: Store Speed Optimization How to make a horrible shop Basics for design change How to search the forums

 

Useful contributions: Easypopulate Fast, Easy Checkout Header Tag Controller

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...