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

How to change the countries order in the list for registration?

Started by rvbgnu, June 29, 2012, 00:37:17 AM

Previous topic - Next topic

rvbgnu

Hi great VM community!

I want to sort the countries list for my main customers (Ireland, UK, USA, and other european countries). The Idea is to have first these main countries, and then the rest of the list. There is a field "ordering" in the table "_virtuemart_countries ", but i tried to put some values, with no effect.
Anyone has an idea on how to change this?

Probably a template override on editaddress.php, like in the post about the default country. Thanks raycarter!
http://forum.virtuemart.net/index.php?topic=97563.msg337782#new
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

raycarter

HI,

I am in a hurry but someone else or you yourself with a bit of jquery can do this in the same layout.

just define an array containing ids of countries that you need to get on top. values should be in order :
then loop through them and place them on top.

THis is js code put it in the existing jquery ready event code on the page.





var countriestotop = new Array("56,57,102,203");
for (i=0; i<countriestotop.length ; i++){
if(i==0) jQuery('select#virtuemart_country_id option[value=countriestotop[i]]').append('select#virtuemart_country_id');
else
jQuery('select#virtuemart_country_id option[value=countriestotop[i]]').after('select#virtuemart_country_id li:eq(i-1)');

}


not tested.

rvbgnu

Thanks RayCarter, I will try this and get back here with the result!
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

MADmarion

Did this solution work for you?  Where did you put the code?

I cant solve this unfortunately.

raycarter

It must work.

Copy this file : <siteroot>/components/com_virtuemart/views/user/edit_address.php

And place it under : <siteroot>/templates/<yourcurrenttemplate>/html/com_virtuemart/user/edit_address.php

And then at the top of the html code (outside the php tags) place the script

<script type="text/javascript">
var countriestotop = new Array("56,57,102,203"); //ids of countries that you need to get on top.
for (i=0; i<countriestotop.length ; i++){
if(i==0) jQuery('select#virtuemart_country_id option[value=countriestotop[i]]').append('select#virtuemart_country_id');
else
jQuery('select#virtuemart_country_id option[value=countriestotop[i]]').after('select#virtuemart_country_id li:eq(i-1)');
</script>


Test and reply.

EDIT: I am not sure f it worked for you or not. Just dont run away after you see something worked or didnt work for you, instead come and leave a reply here for others to know. had the first guy done that you wouldnt need to ask, if you do it, the next person wont ask.
The reason people dont reply is the reason developers dont wish to help anymore. We are a community and must help each other, give and take is the principle.



MADmarion

Sorry for replying late. Had to fix many other issues in VM2 before I could try again to fix this one.

Unfortunately, your solution did not work for me.

I also tried the solution in this thread that modifies the php code, but whatever I try, country order stays the same (name/ASC).
http://forum.virtuemart.net/index.php?topic=101860.msg337881#msg337881

Really have no idea, why both solutions just dont change anything.

raycarter

Change the $ sign with jQuery and see if it works. Also when the page loads, right click to open inspector and check the console tab for any errors.

If there is an error referring to the code i wrote report back. If all is Okay then pm me your website address and even FTP.

ivan763

Quote from: raycarter on November 26, 2012, 21:40:52 PM

EDIT: I am not sure f it worked for you or not. Just dont run away after you see something worked or didnt work for you, instead come and leave a reply here for others to know. had the first guy done that you wouldnt need to ask, if you do it, the next person wont ask.
The reason people dont reply is the reason developers dont wish to help anymore. We are a community and must help each other, give and take is the principle.

isn't working for me.

but i found the solution:
File:/components/com_virtuemart/assets/js/vmsite.js
after line 18 ( methods.update(this,dest,ids);  )
add:

$('#virtuemart_country_id option[value="176"]').attr('selected', 'selected');
$(this).each( function() { methods.update(this,dest)});

it's working for me.




raycarter

Quote from: ivan763 on January 14, 2013, 17:11:04 PM
Quote from: raycarter on November 26, 2012, 21:40:52 PM

EDIT: I am not sure f it worked for you or not. Just dont run away after you see something worked or didnt work for you, instead come and leave a reply here for others to know. had the first guy done that you wouldnt need to ask, if you do it, the next person wont ask.
The reason people dont reply is the reason developers dont wish to help anymore. We are a community and must help each other, give and take is the principle.

isn't working for me.

but i found the solution:
File:/components/com_virtuemart/assets/js/vmsite.js
after line 18 ( methods.update(this,dest,ids);  )
add:

$('#virtuemart_country_id option[value="176"]').attr('selected', 'selected');
$(this).each( function() { methods.update(this,dest)});

it's working for me.





Did you try what i wrote above?

Quote from: raycarter on December 08, 2012, 13:34:55 PM
Change the $ sign with jQuery and see if it works. Also when the page loads, right click to open inspector and check the console tab for any errors.

If there is an error referring to the code i wrote report back. If all is Okay then pm me your website address and even FTP.

softpill