Author Topic: VM 3.0.8 - How to Re-order Country List in Cart Dropdown?  (Read 2805 times)

XenoGen

  • Beginner
  • *
  • Posts: 5
VM 3.0.8 - How to Re-order Country List in Cart Dropdown?
« on: September 02, 2015, 18:16:50 pm »
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

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3510
  • VirtueMart Version: 3.8.9
Re: VM 3.0.8 - How to Re-order Country List in Cart Dropdown?
« Reply #1 on: September 02, 2015, 19:38:28 pm »
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.9.27
php 7.4

XenoGen

  • Beginner
  • *
  • Posts: 5
Re: VM 3.0.8 - How to Re-order Country List in Cart Dropdown?
« Reply #2 on: September 03, 2015, 13:45:22 pm »
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

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 10579
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.8.8
Re: VM 3.0.8 - How to Re-order Country List in Cart Dropdown?
« Reply #3 on: September 03, 2015, 15:07:51 pm »
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
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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

  • Beginner
  • *
  • Posts: 33
  • A beginner
Re: VM 3.0.8 - How to Re-order Country List in Cart Dropdown?
« Reply #4 on: August 22, 2017, 16:00:07 pm »
Hi,
might be you could try to change ordring in this file: administrator/components/com_virtuemart/helpers/vmmodel.php
line 651 _getOrdering function