News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Set a Default Country during Registration / Checkout

Started by Rabble, February 05, 2012, 19:03:39 PM

Previous topic - Next topic

wnycomputerguy

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.


jenkinhill

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.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

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

AH

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


VopoloS

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?

jenkinhill

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.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

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

VopoloS

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

jjk

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

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?

jjk

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

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.