Author Topic: Set a Default Country during Registration / Checkout  (Read 26109 times)

Rabble

  • Beginner
  • *
  • Posts: 14
Set a Default Country during Registration / Checkout
« on: February 05, 2012, 19:03:39 pm »
How can I set the default country during checkout?  I want to set it to be the USA.  I have filled out the address fields under Shop -> Additional Information, but this doesn't seem to pre-select the country.


No need to do any coding this is a simple parameter setting in the Shopper field, "virtuemart_country_id"

Thanks to Jenkinhill's knowledge!!

No need for any scripting or code changes VM2 supports this via a simple parameter

Just go to the VM/Admin/Shopper fields

Select virtuemart_country_id Move to the Default box and enter the ID # you want to use and Voila!

223 is USA

[attachment cleanup by admin]

Rabble

  • Beginner
  • *
  • Posts: 14
Re: How to Set a Default Country during Registration / Checkout?
« Reply #1 on: February 07, 2012, 16:52:07 pm »
There must be a way to do this, any info is appreciated!

Rabble

  • Beginner
  • *
  • Posts: 14
Re: How to Set a Default Country during Registration / Checkout?
« Reply #2 on: February 10, 2012, 04:50:45 am »
Bump for a point in the right direction... is this working for everyone else?

John2400

  • Virtuemart - the Future is ever Changing
  • Global Moderator
  • Full Member
  • *
  • Posts: 1568
  • VirtueMart Version: Use VM3.6+
Re: How to Set a Default Country during Registration / Checkout?
« Reply #3 on: February 10, 2012, 09:28:29 am »
Hi the only way I did this was to unpublish any country I was not going to sell to. Thus for me I'm only selling to USA then - unpublish everyone else.
Thus your list becomes only a few countries - and is very quick for the customer to pick.

not automatic but very easy -

Rabble

  • Beginner
  • *
  • Posts: 14
Re: How to Set a Default Country during Registration / Checkout?
« Reply #4 on: February 11, 2012, 22:31:40 pm »
Thanks for the info John!  If I was only selling in the USA, this would work, but I'm planning to offer worldwide shipping.   :-\

markito

  • Beginner
  • *
  • Posts: 35
Re: How to Set a Default Country during Registration / Checkout?
« Reply #5 on: February 14, 2012, 15:39:30 pm »
Hi

Is there no way to set a country for default? Otherwise i think for customers is not realy userfrendly.
Anybody have a idea how to set some country as default in VM2?

would be great! thx

Limonbay

  • Jr. Member
  • **
  • Posts: 54
  • Piercing life
    • Piercings
Re: How to Set a Default Country during Registration / Checkout?
« Reply #6 on: March 01, 2012, 01:24:16 am »
I'm also interested in this information. Anyone?  :P
Piercings y complementos
http://www.limonbay.com
Joomla 2.5.14
Virtuemart 2.0.24

John2400

  • Virtuemart - the Future is ever Changing
  • Global Moderator
  • Full Member
  • *
  • Posts: 1568
  • VirtueMart Version: Use VM3.6+
Re: How to Set a Default Country during Registration / Checkout?
« Reply #7 on: March 01, 2012, 06:09:21 am »
Hi great idea,

maybe just re- write this in bugs and feature ideas forum.

with 200 plus countries on the list alone I think this is a great featrure to have.

raycarter

  • Beginner
  • *
  • Posts: 39
Re: How to Set a Default Country during Registration / Checkout?
« Reply #8 on: April 25, 2012, 13:50:09 pm »
As a quick fix you can add the following lines at the top of this file after the line:
JHTML::_('behavior.formvalidation');

Location : <jroot>/components/com_virtuemart/views/user/edit_address.php

Or override in the joomla template <jroot>/templates/<yourtemplate>/html/com_virtuemart/user/edit_address.php.

-223 is the id of USA, you can change it to your default country. You can look the id up either in the database or by inspecting the html of country drop down.

Code: [Select]
<script type="text/javascript">
    jQuery(document).ready(function($) {
  if ($('#virtuemart_country_id option:selected').attr('value')=="")
    $('#virtuemart_country_id option[value="223"]').attr('selected', 'selected').change();

if ($('#shipto_virtuemart_country_id option:selected').attr('value')=="")
    $('#shipto_virtuemart_country_id option[value="223"]').attr('selected', 'selected').change();

});

</script>

eldravo

  • Beginner
  • *
  • Posts: 16
Re: How to Set a Default Country during Registration / Checkout?
« Reply #9 on: April 27, 2012, 03:57:26 am »
raycarter

Thanks for this solution.

Could you be more specific on where to insert those lines? In between what lines?

I have made those changes and have an error:

Parse error: syntax error, unexpected '<' in ......mysite/components/com_virtuemart/views/user/tmpl/edit_address.php on line 31

eldravo

  • Beginner
  • *
  • Posts: 16
Re: How to Set a Default Country during Registration / Checkout?
« Reply #10 on: April 27, 2012, 04:12:27 am »
raycarter


I tried to move your code to some other place and it worked well on the preselection of the country.

Unfortunately the "state" field is not giving me the dropdown list anymore. It is not working as it used when I select the country manually.

I had to remove all your code. We're almost there. Thanks for your effort. Perhaps you or someone could do more testing and modifications.

Regards,

eldravo

baggeler

  • Jr. Member
  • **
  • Posts: 78
    • Orgonite Brasil
  • Skype Name: bernhard_aggeler
  • VirtueMart Version: 3.2
Re: How to Set a Default Country during Registration / Checkout?
« Reply #11 on: April 30, 2012, 01:28:58 am »
See the feature request I made here http://forum.virtuemart.net/index.php?topic=101906.msg338092#msg338092, there are two links with different codes to implement

Hope this helps,
Please post your results
________________________________________
The more I know the more I know I don´t know
Socrates

Site: www.orgonite-brasil.com
Tech: Joomla 3.7.3,  Virtuemart 3.2

raycarter

  • Beginner
  • *
  • Posts: 39
Re: How to Set a Default Country during Registration / Checkout?
« Reply #12 on: May 01, 2012, 19:18:20 pm »
Hi,

I am sorry i did not get back to it. I will update the code as soon as i get time.

EDIT: Check my previous post. I modified the code. I forgot that the drop down had to fire the change event. All good now.




rvbgnu

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 137
    • Puma-IT.ie
Re: How to Set a Default Country during Registration / Checkout?
« Reply #13 on: June 29, 2012, 00:38:19 am »
Thanks raycarter! I was exactly looking at this !!

Any idea on How to change the countries order in the list for registration?
http://forum.virtuemart.net/index.php?topic=104584.0
Best Regards, Hervé Boinnard - Irish Time (GMT)
Joomla! multilingual website and online business made easy - https://www.puma-it.ie

3D Secure v1 (3DS1) & Strong Customer Authentication (SCA)! Stripe.com payment plugin for VirtueMart 3: https://www.puma-it.ie/en/joomla-and-virtuemart-extensions/stripe-for-virtuemart
Authipay (AIB Merchant Services) for VirtueMart 2 & 3: https://www.puma-it.ie/en/joomla-and-virtuemart-extensions/authipay-aib-merchant-services-for-virtuemart

vasite

  • Beginner
  • *
  • Posts: 2
Re: How to Set a Default Country during Registration / Checkout?
« Reply #14 on: December 10, 2012, 00:31:32 am »
Hi guys
I think that I found what you are looking for.
You can set a default country on registration from your Sql database.
Go to table virtuemart_userfields and virtuemart_country_id.
Set default value with your country's id as listed on virtuemart_countries.
That's all!  ;)