Author Topic: Set a Default Country during Registration / Checkout  (Read 28968 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: 28746
  • 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 4.2.5 10924 J! 3.10.11 PHP 8.2.7

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3517
  • VirtueMart Version: 4.0.12.10777
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.10.11
php 8.0

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: 28746
  • 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 4.2.5 10924 J! 3.10.11 PHP 8.2.7

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: 3764
  • 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: 3764
  • 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.