News:

Looking for documentation? Take a look on our wiki

Main Menu

VM 3.0.8 - How to Re-order Country List in Cart Dropdown?

Started by XenoGen, September 02, 2015, 18:16:50 PM

Previous topic - Next topic

XenoGen

I'm using Virtuemart 3.0.8 with the latest Joomla 3.4.1.
Everything is working 100% properly like it should. I have no issues there.

On the Cart page, when the users selects their country from the dropdown box, it lists them in alphabetical order, starting with Afgahnistan.
How can I re-order them?

I don't believe there is any administration setting to do that, so I could a few code changes will be required. if I'm wrong, though, let me know. I've tried renaming Afghanistan to see if if stays first, but it doesn't - so the list is alphabetized somehow. I used to know how to re-order them with a few code changes in VM2, but that doesn't work here in VM3.

Essentially, I'm looking to put "US", "Canada", and "UK" at the top of the list, then the rest of the countries in alphabetical order.
Anyone have a few ideas, or lines of code I can edit a file with?

Thanks!

AH

There is an ordering field in the country database that appears to not show in the administration field for countries

I shall see if anyone knows why this is not used

Regards
A

Joomla 3.10.11
php 8.0

XenoGen

Thanks for checking into it.

For fun, I modified the ID and Ordering values in the actual Database, but it didn't have any effect on the site's country order. Thought I'd test.

Alternatively, I came up with the idea that if I changed the name of "Canada" to "-- Canada --" and "United States" to "-- United States --", that alphabetically they would be listed first, and it would be an acceptable workaround.

It worked in the admin - they are listed above Afghanistan in the country list. BUT on the front end, in the actual cart dropdown, the "--" are filtered out of the name.

Anyone have any ideas what line of code strips out the non-alphabetical characters out of the Country name? If figure, if I could remove that filter, that I'd have an acceptable solution for the moment. Thanks!

GJC Web Design

function renderCountryList()

components\com_virtuemart\helpers\shopfunctionsf.php ~  line 174

the list is got from  function getCountries() administrator\components\com_virtuemart\models\country.php ~ line 93

you could change the query there to take notice of the order
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

florihana

Hi,
might be you could try to change ordring in this file: administrator/components/com_virtuemart/helpers/vmmodel.php
line 651 _getOrdering function