Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Set default country for customers?


Tsimi

Recommended Posts

Hello Tsimi,

Easiest solution I saw in many shops is to remove all countries from the database except the one you sell to.

Next step could be to change the country drop down menu to a static text with the country and change the database input to fix country value.

rgds

Rainer

Link to comment
Share on other sites

Thanks Rainer.

I am not sure this following approach is correct but it does seem to work. All entries are inside the database and it does show correct inside the address book area.
I used tep_draw_hidden_field to hide the input field completely and also added the class hidden to hide the whole country piece on the create account page.
It only requires the country ID number, in my case 107 for Japan.

Something like this

    <div class="form-group has-feedback hidden">
      <label for="inputCountry" class="control-label col-sm-3"><?php echo ENTRY_COUNTRY; ?></label>
      <div class="col-sm-9">
        <?php
        echo tep_draw_hidden_field('country', '107');
        //echo tep_get_country_list('country', NULL, 'required aria-required="true" aria-describedby="atCountry" id="inputCountry"');
        //echo FORM_REQUIRED_INPUT;
        //if (tep_not_null(ENTRY_COUNTRY_TEXT)) echo '<span id="atCountry" class="help-block">' . ENTRY_COUNTRY_TEXT . '</span>';
        ?>
      </div>
    </div>

Now I need to go through the rest of the pages/files to hide the country part there as well.
Here it is not needed if you only do domestic business and it would look stupid for a domestic shop to show the country part somewhere within the account area.

Link to comment
Share on other sites

  • You need to advice somewhere in the store that you will only ship and sell domestic. If this info is easy and clear to see for the customer, yes that's a nice solution. I just thought the best place to give this info is on the pages where the address is used by an info text below the country field for example.
  • Removing countries in the db is one job, modifying all pages where the country is used is more work :smile:
Link to comment
Share on other sites

The store is in Japanese only so I highly doubt that some foreigner is gonna try to purchase anything.
Of course the shop will have a FAQ site with all the necessary payment and shipping info.

But you are right it will be a tedious work to hide all the country pieces inside the orders and account area.

Wish there would be some modularity in such things where you can just simply got to the admin area and flip a switch.

Show/use "Countries"? On/Off or True/False

If set to Off or False hide it inside all relevant files.
One day maybe....

Thanks again for the quick help. :smile::thumbsup:


 

Link to comment
Share on other sites

14 minutes ago, Tsimi said:

Wish there would be some modularity in such things where you can just simply got to the admin area and flip a switch.

Show/use "Countries"? On/Off or True/False

If set to Off or False hide it inside all relevant files.
One day maybe....

Just asked @burt about this yesterday!  I also wish I could rearrange the input fields in account creating page by simply giving them sort order...

Cheers, Eddy

Link to comment
Share on other sites

1 hour ago, Moxamint said:

Just asked @burt about this yesterday!  I also wish I could rearrange the input fields in account creating page by simply giving them sort order...

Cheers, Eddy

I was thinking about something similar the other week. I  sell mainly to UK addresses and the address layout is set up for this. Now say I sell to the USA, where the address layout is different. It causes confusion to the customers and to me when sorting the address labels. If they pay using PayPal I usually copy and past the verified address from there, but some pay using other payment methods.

So could something be done to the address layout depending on the customers IP address, or even their country. Only trouble I see with country is that it would need to be set before any other of the address.

REMEMBER BACKUP, BACKUP AND BACKUP

Link to comment
Share on other sites

I have done this a time ago..  in youre db add a column(field) int type with the name ‘active’ in the ‘countries’ table

Select youre countries to ‘1’ which you want in the drop down.

In catalog/includes/functions/general.php search for;

$countries = tep_db_query("select countries_id, countries_name from " . TABLE_COUNTRIES . " order by countries_name");

and change with;

$countries = tep_db_query("select countries_id, countries_name from " . TABLE_COUNTRIES . " WHERE active='1' order by countries_name");

 

active.png

active_land.png

Link to comment
Share on other sites

Another way;

<script>
$('#inputCountry').val("<?php echo STORE_COUNTRY; ?>").attr('readonly', 'readonly'); 
</script>

Add that to each page on which there is a country dropdown.  I'd do it as a module, loaded into footer_scripts.  Easy to then amend, turn off etc, and no core changes needed.  

Code assumes that STORE_COUNTRY (set at admin > configuration > my store) is same country as where customers are.

Note:  Code is UNTESTED.

Link to comment
Share on other sites

@Tsimi

 

6 hours ago, Tsimi said:

a FAQ site with all the necessary payment and shipping info.

But you are right it will be a tedious work to hide all the country pieces inside the orders and account area.

Wish there would be some modularity in such things where you can just simply got to the admin area and flip a switch.

Show/use "Countries"? On/Off or True/False

If set to Off or False hide it inside all relevant files.
One day maybe....

Thanks again for the quick help. :smile::thumbsup:


 

 

This one will do that for you. It's old, but can be adapted to EDGE (I've done it). I use this in all of my stores. It requires a LOT of core changes, though ...

https://apps.oscommerce.com/aKZPh&active-countries

HTH

Malcolm

Link to comment
Share on other sites

@burt

3 hours ago, burt said:

Another way;


<script>
$('#inputCountry').val("<?php echo STORE_COUNTRY; ?>").attr('readonly', 'readonly'); 
</script>

Add that to each page on which there is a country dropdown.  I'd do it as a module, loaded into footer_scripts.  Easy to then amend, turn off etc, and no core changes needed.  

Code assumes that STORE_COUNTRY (set at admin > configuration > my store) is same country as where customers are.

Note:  Code is UNTESTED.

Maybe for this years 28 day module? :cool:

Malcolm

Link to comment
Share on other sites

1 hour ago, burt said:

Possibility, would it be of use ?

Maybe something a bit more extended which allows

  1. select a default country
  2. optionally make it not changable
  3. remove unwanted countries

Thoughts?

...or remove or hide the country select field shop wide?

Link to comment
Share on other sites

Good UI design would be to at least make country selection Read-Only if there is only one country allowed (all others removed from the DB or better, "active=0"). As long as it's visually clear that only one country is allowed, anything fancier (e.g., changing the drop-down to fixed text) is icing on the cake. Avoiding any deeper changes is good, as it allows future support of multiple countries if you choose to sell internationally. If multiple countries are allowed, the country needs to be selected before any activity on entering an address.

While on the subject, one need would be to allow countries by merchandise class -- say, digital downloads to any non-embargoed country, and physical goods only domestically (filling out customs forms is such a pain for low margin items). Whether or not to include VAT in the price would be a country-related issue, as would shipping choices.

Link to comment
Share on other sites

@raiwa

Found an easier way.

I just use your State Selector BS add-on and set Use Store Country by Default to True.
Then I just need to hide the country drop-down on all 3 relevant pages by using the hidden class, done.

Now not only is the country part hidden and already pre-selected but it also activates the state drop-down which is far better then typing it manually.

Well done! :thumbsup:

Link to comment
Share on other sites

Thank You @Tsimi, but all credits still belong to @De Dokta, RIP.

I just packed his code into the add-on. Besides I believe some kind of state selector should be core.

rgds

Rainer

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...