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

Rabble

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

There must be a way to do this, any info is appreciated!

Rabble

Bump for a point in the right direction... is this working for everyone else?

John2400

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

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

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

Piercings y complementos
http://www.limonbay.com
Joomla 2.5.14
Virtuemart 2.0.24

John2400

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

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>

eldravo

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

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

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

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

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

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!  ;)