News:

Support the VirtueMart project and become a member

Main Menu

Virtuemart 3 Australia to use 3 digit state code

Started by sagaranvekar, December 01, 2015, 09:51:26 AM

Previous topic - Next topic

sagaranvekar

Hello,

I am using VirtueMart 3.0.12 and Joomla! 3.4.5 .

I can see that i have 3 digit State codes[State (3) Code] already there in Configuration -> Countries -> Australia [States] -> States.
Currently, i am using paypal sandbox to test payments. When i tried to place an order, and i got redirected to Paypal.
And Instead of NSW, i can see NS as state code.

I tried searching in shop configuration to change state code from 2 digit to 3 digit, but i cannot find any configuration in shop to change it.

Please help me with this so that, i can use 3 digit state code [State (3) Code]. Attached along a screenshot of Paypal payment page where it shows 2 digit state code instead of 3 digit.

Thank you in advance.

GJC Web Design

in plugins\vmpayment\paypal\paypal\helpers\paypalstd.php try changing

$post_variables['state'] = isset($address->virtuemart_state_id) ? ShopFunctions::getStateByID($address->virtuemart_state_id, 'state_2_code') : '';

to

$post_variables['state'] = isset($address->virtuemart_state_id) ? ShopFunctions::getStateByID($address->virtuemart_state_id, 'state_3_code') : '';
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

sagaranvekar

GJC Web Design, thank you very much for getting back to me.

I tried applying the change you suggested. But instead of showing NSW (New South Wales), it is now showing "AC" . It was "NS" before.

GJC Web Design

don't see how

it is a very simple func

$fld Field to return: state_name (default), state_2_code or state_3_code.

static public function getStateByID ($id, $fld = 'state_name') {

      if (empty($id)) {
         return '';
      }
      $db = JFactory::getDBO ();
      $q = 'SELECT ' . $db->escape ($fld) . ' AS fld FROM `#__virtuemart_states` WHERE virtuemart_state_id = "' . (int)$id . '"';
      $db->setQuery ($q);
      $r = $db->loadObject ();
      return $r->fld;
   }
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

Typhoon365

We found ourselves for Australian addresses, we need to pass the full state name to PayPal, not the state code.  Found this by googling in the past but can't seem to find the reference to it now.

This is what we use and seems to work last time I checked a couple months ago, haven't checked it recently though.

Quote$post_variables['state'] = isset($address->virtuemart_state_id) ? ShopFunctions::getStateByID($address->virtuemart_state_id, 'state_name') : '';