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

wnycomputerguy

  • Beginner
  • *
  • Posts: 1
Re: How to Set a Default Country during Registration / Checkout?
« Reply #15 on: March 05, 2013, 23:42:31 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>

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.

raycarter

  • Beginner
  • *
  • Posts: 39
Re: How to Set a Default Country during Registration / Checkout?
« Reply #16 on: April 04, 2013, 13:27:27 pm »
Glad it worked out for you.


jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 28263
  • Always on vacation
    • Jenkin Hill Internet
Re: How to Set a Default Country during Registration / Checkout?
« Reply #17 on: May 17, 2013, 16:43:23 pm »
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.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VirtueMart 3.8.9.10473 on Joomla 3.9.28 PHP 7.4.14

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3506
  • VirtueMart Version: 3.8.9
Re: How to Set a Default Country during Registration / Checkout?
« Reply #18 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]
Regards
A

Joomla 3.9.27
php 7.4

softpill

  • Beginner
  • *
  • Posts: 3
  • Skype Name: unixbreak
Re: Set a Default Country during Registration / Checkout
« Reply #19 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/

hope will helps

VopoloS

  • Jr. Member
  • **
  • Posts: 55
Re: Set a Default Country during Registration / Checkout
« Reply #20 on: July 19, 2016, 06:42:24 am »
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?

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 28263
  • Always on vacation
    • Jenkin Hill Internet
Re: Set a Default Country during Registration / Checkout
« Reply #21 on: July 19, 2016, 10:08:39 am »
Is there a hack for Virtuemart 3?

It's not a hack. It is a simple configuration option to set default country.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VirtueMart 3.8.9.10473 on Joomla 3.9.28 PHP 7.4.14

VopoloS

  • Jr. Member
  • **
  • Posts: 55
Re: Set a Default Country during Registration / Checkout
« Reply #22 on: July 19, 2016, 10:48:12 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

jjk

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3738
  • using Matomo instead of Google Analytics
Re: Set a Default Country during Registration / Checkout
« Reply #23 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:
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

VopoloS

  • Jr. Member
  • **
  • Posts: 55
Re: Set a Default Country during Registration / Checkout
« Reply #24 on: July 19, 2016, 21:12:42 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?

jjk

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3738
  • using Matomo instead of Google Analytics
Re: Set a Default Country during Registration / Checkout
« Reply #25 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'!)
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

VopoloS

  • Jr. Member
  • **
  • Posts: 55
Re: Set a Default Country during Registration / Checkout
« Reply #26 on: July 20, 2016, 07:04:27 am »
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.