VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: Rabble on February 05, 2012, 19:03:39 PM

Title: Set a Default Country during Registration / Checkout
Post by: Rabble 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]
Title: Re: How to Set a Default Country during Registration / Checkout?
Post by: Rabble on February 07, 2012, 16:52:07 PM
There must be a way to do this, any info is appreciated!
Title: Re: How to Set a Default Country during Registration / Checkout?
Post by: Rabble on February 10, 2012, 04:50:45 AM
Bump for a point in the right direction... is this working for everyone else?
Title: Re: How to Set a Default Country during Registration / Checkout?
Post by: John2400 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 -
Title: Re: How to Set a Default Country during Registration / Checkout?
Post by: Rabble 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.   :-\
Title: Re: How to Set a Default Country during Registration / Checkout?
Post by: markito 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
Title: Re: How to Set a Default Country during Registration / Checkout?
Post by: Limonbay on March 01, 2012, 01:24:16 AM
I'm also interested in this information. Anyone?  :P
Title: Re: How to Set a Default Country during Registration / Checkout?
Post by: John2400 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.
Title: Re: How to Set a Default Country during Registration / Checkout?
Post by: raycarter 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.

<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>
Title: Re: How to Set a Default Country during Registration / Checkout?
Post by: eldravo 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
Title: Re: How to Set a Default Country during Registration / Checkout?
Post by: eldravo 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
Title: Re: How to Set a Default Country during Registration / Checkout?
Post by: baggeler 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
Title: Re: How to Set a Default Country during Registration / Checkout?
Post by: raycarter 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.



Title: Re: How to Set a Default Country during Registration / Checkout?
Post by: rvbgnu 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
Title: Re: How to Set a Default Country during Registration / Checkout?
Post by: vasite 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!  ;)
Title: Re: How to Set a Default Country during Registration / Checkout?
Post by: wnycomputerguy on March 05, 2013, 23:42:31 PM
Quote from: raycarter 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.

<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>


I can verify this works perfectly as of 2.0.18a

I inserted it into my template override file (<jroot>/templates/<yourtemplate>/html/com_virtuemart/user/edit_address.php) directly below the existing script, starting at line 71.

It could probably be put directly within the existing script tags but I'm a big proponent of "if it ain't broke, don't fix it" :) - I pasted the whole thing in there, it worked, I moved on.
Title: Re: How to Set a Default Country during Registration / Checkout?
Post by: raycarter on April 04, 2013, 13:27:27 PM
Glad it worked out for you.

Title: Re: How to Set a Default Country during Registration / Checkout?
Post by: jenkinhill on May 17, 2013, 16:43:23 PM
Quote from: Hutson on May 17, 2013, 11:50:04 AM
VM should allow for a country to be set as a default for shipping/bt addresses.

It does. Shppper fields/virtuemart_country_id - set default country code just uner the description editor.
Title: Re: How to Set a Default Country during Registration / Checkout?
Post by: AH on May 17, 2013, 18:00:36 PM
As per usual, I am humbled by 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, 222 is UK




[attachment cleanup by admin]
Title: Re: Set a Default Country during Registration / Checkout
Post by: softpill on October 01, 2013, 18:24:55 PM
Follow this tutorial for a quick hack in changing the countries order

http://blog.softpill.eu/how-to-change-countries-order-on-virtuemart/ (http://blog.softpill.eu/how-to-change-countries-order-on-virtuemart/)

hope will helps
Title: Re: Set a Default Country during Registration / Checkout
Post by: VopoloS on July 19, 2016, 06:42:24 AM
Quote from: AH on May 17, 2013, 18:00:36 PM
As per usual, I am humbled by 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, 222 is UK



Is there a hack for Virtuemart 3?
Title: Re: Set a Default Country during Registration / Checkout
Post by: jenkinhill on July 19, 2016, 10:08:39 AM
Quote from: SolopoV on July 19, 2016, 06:42:24 AM
Is there a hack for Virtuemart 3?

It's not a hack. It is a simple configuration option to set default country.
Title: Re: Set a Default Country during Registration / Checkout
Post by: VopoloS on July 19, 2016, 10:48:12 AM
Quote from: jenkinhill on July 19, 2016, 10:08:39 AM
Quote from: SolopoV on July 19, 2016, 06:42:24 AM
Is there a hack for Virtuemart 3?

It's not a hack. It is a simple configuration option to set default country.
Please tell me the url where the exposed configuration the default country or a screenshot. I for some reason is not the default country. Maybe because you installed the OPC, then OPC is removed from rupostel
Title: Re: Set a Default Country during Registration / Checkout
Post by: jjk on July 19, 2016, 14:26:40 PM
It's still at the same position as shown in AH's screenshot from 2013 above:
See new screenshot below:
Title: Re: Set a Default Country during Registration / Checkout
Post by: VopoloS on July 19, 2016, 21:12:42 PM
Quote from: jjk on July 19, 2016, 14:26:40 PM
It's still at the same position as shown in AH's screenshot from 2013 above:
See new screenshot below:
Thank you, Yes it is a field I have filled. 176 ID is what I need. But at the front of the site, the country is still not automatically selected. The seller is also in the Russian Federation. In the database this ID is also recorded. It is possible to record the default country is still somewhere in the config file?
Title: Re: Set a Default Country during Registration / Checkout
Post by: jjk on July 19, 2016, 22:31:29 PM
Did you try to clear the VirtueMart and browser cache after you entered the number 176 into the field? (only the number, not 'ID 176'!)
Title: Re: Set a Default Country during Registration / Checkout
Post by: VopoloS on July 20, 2016, 07:04:27 AM
Quote from: jjk on July 19, 2016, 22:31:29 PM
Did you try to clear the VirtueMart and browser cache after you entered the number 176 into the field? (only the number, not 'ID 176'!)
I did so and still did not help. Probably left over "tails" from the OPC, I don't know where else to look.