Welcome, Guest. Please login or register.
Login with username, password and session length


It's a release candidate! VirtueMart 2.0 RC - the next generation VirtueMart - is available! Read more....

  Advanced search

247038 Posts in 67506 Topics- by 258314 Members - Latest Member: aniketana
Pages: [1]   Go Down
Print
Author Topic: Problem with states ant country display  (Read 7063 times)
ricoma
Newbie
*
Posts: 30


« on: March 10, 2008, 02:47:56 AM »

When the user select his state and country it's displayed correctly. But when it shows the users addresses, it display the state_id instead of the state_name and the 3 letters contry code instead of the country... Can I fix this easily?

thanks a lot
Logged
jagular
Newbie
*
Posts: 15

never ending BFU


« Reply #1 on: June 15, 2008, 10:38:44 AM »

Hi,
in backend Account Maintenance/View Order
if you want to see State Name (no state_2_code)
you can try add this to account.order_details.tpl.php

changhe original code from lines 120-130
Code:
switch($field->name) {
          case 'country':
          require_once(CLASSPATH.'ps_country.php');
          $country = new ps_country();
          $dbc = $country->get_country_by_code($dbbt->f($field->name));
          if( $dbc !== false ) echo $dbc->f('country_name');
          break;
          default:
          echo $dbbt->f($field->name);
          break;
          }


to

Code:
switch($field->name) {
          case 'country':
          require_once(CLASSPATH.'ps_country.php');
          $country = new ps_country();
          $dbc = $country->get_country_by_code($dbbt->f($field->name));
          if( $dbc !== false ) echo $dbc->f('country_name');
          break;
         
          case 'state':
$db = new ps_DB();
$q = "SELECT state_name FROM #__{vm}_state WHERE #__{vm}_state.country_id = ";
$q .= "(SELECT country_id FROM #__{vm}_country WHERE #__{vm}_country.country_3_code = '".$dbbt->f('country')."') ";
$q .= "AND #__{vm}_state.state_2_code = '".$dbbt->f('state')."' ";
$db->query($q);
$db->next_record();
echo $db->f( 'state_name' );              
          break;
         
          default:
          echo $dbbt->f($field->name);
          break;
          }

and original code from lines 163-168

Code:
switch($field->name) {
          case 'country':
          require_once(CLASSPATH.'ps_country.php');
          $country = new ps_country();
          $dbc = $country->get_country_by_code($dbst->f($field->name));
          if( $dbc !== false ) echo $dbc->f('country_name');
          break;
          default:
          echo $dbst->f($field->name);
          break;
          }

modify to

Code:
switch($field->name) {
          case 'country':
          require_once(CLASSPATH.'ps_country.php');
          $country = new ps_country();
          $dbc = $country->get_country_by_code($dbst->f($field->name));
          if( $dbc !== false ) echo $dbc->f('country_name');
          break;
         
          case 'state':
$db = new ps_DB();
$q = "SELECT state_name FROM #__{vm}_state WHERE #__{vm}_state.country_id = ";
$q .= "(SELECT country_id FROM #__{vm}_country WHERE #__{vm}_country.country_3_code = '".$dbbt->f('country')."') ";
$q .= "AND #__{vm}_state.state_2_code = '".$dbbt->f('state')."' ";
$db->query($q);
$db->next_record();
echo $db->f( 'state_name' );              
          break;
         
          default:
          echo $dbst->f($field->name);
          break;
          }

(just add new case 'state': ***)

if anybody know better solution ...



« Last Edit: June 15, 2008, 13:40:27 PM by jagular » Logged
jagular
Newbie
*
Posts: 15

never ending BFU


« Reply #2 on: June 15, 2008, 11:50:49 AM »

And if you like to see State Name on Checkout - Ship To Address
you can modify list_shipto_addresses.tpl.php


Code:
echo $db->f("state_2_code") . " ";

edit to

Code:
echo $db->f("state_name") . " ";

// for state, can be used: state_name, state_2_code, state_3_code

 Wink
« Last Edit: June 15, 2008, 13:39:27 PM by jagular » Logged
investigacion
Newbie
*
Posts: 31


« Reply #3 on: December 29, 2008, 12:52:33 PM »

When add this code, state is view OK, but no view total price

Huh?

Why?

Joomla 1.5.8
virtuemart 1.1.2
Logged
jagular
Newbie
*
Posts: 15

never ending BFU


« Reply #4 on: January 04, 2009, 12:29:18 PM »

ups,

change for example to this

Code:
          case 'state':
$dbst1 = new ps_DB();
$q = "SELECT state_name FROM #__{vm}_state WHERE #__{vm}_state.country_id = ";
$q .= "(SELECT country_id FROM #__{vm}_country WHERE #__{vm}_country.country_3_code = '".$dbbt->f('country')."') ";
$q .= "AND #__{vm}_state.state_2_code = '".$dbbt->f('state')."' ";
$dbst1->query($q);
$dbst1->next_record();
echo $dbst1->f( 'state_name' );              
          break;



to something unique

Code:
$db

to

Code:
$dbst1


Logged
investigacion
Newbie
*
Posts: 31


« Reply #5 on: January 06, 2009, 10:57:53 AM »

OK, THANKS.

This modifications is only for:
Account Maintenance/View Order
if you want to see State Name (no state_2_code)
you can try add this to account.order_details.tpl.php


I have same problem in orders

se photo attach


* orders.jpg (130.81 KB, 932x818 - viewed 600 times.)
« Last Edit: January 06, 2009, 11:22:57 AM by investigacion » Logged
akeem76
Newbie
*
Posts: 18


« Reply #6 on: March 02, 2009, 03:39:40 AM »

Thank you for the guide.

But there are some more files that need to be changed too:
order.order_print.php -> during order preview at backend admin
order.order_printdetails.php -> same as above
confirmation_email.tpl.php -> for confirmation email

I had tried to directly put the coding given in the previous conversation. But there is error.

Appreciate very much jagular if you could extend this to the other 3 files too.

Thank you.

Logged
jagular
Newbie
*
Posts: 15

never ending BFU


« Reply #7 on: April 18, 2009, 07:58:00 AM »

/administrator/components/com_virtuemart/html/order.order_print.php

same way:
add on lines 210-220 between case country and default:

Code:
// hack - state name          
case 'state':
   $dbst1 = new ps_DB();
   $q = "SELECT state_name FROM #__{vm}_state WHERE #__{vm}_state.country_id = ";
   $q .= "(SELECT country_id FROM #__{vm}_country WHERE #__{vm}_country.country_3_code = '".$dbt->f('country')."') ";
   $q .= "AND #__{vm}_state.state_2_code = '".$dbt->f('state')."' ";;
   $dbst1->query($q);
   $jglr_state_name=$dbst1->f( 'state_name' );
   echo $jglr_state_name;
   break;
// end hack - state name

and on lines 259-263 add case state:

Code:
// hack - state name          
case 'state':
   echo $jglr_state_name;
   break;
// end hack - state name

well this is dirty solution, i am not well skilled

i will try find out solution for:
   order.order_printdetails.php
   confirmation_email.tpl.php
« Last Edit: April 18, 2009, 08:03:38 AM by jagular » Logged
jagular
Newbie
*
Posts: 15

never ending BFU


« Reply #8 on: April 18, 2009, 08:35:02 AM »

/administrator/components/com_virtuemart/html/order.order_printdetails.php

state name on vendor address - TODO
      
state name on client address
add on lines 113-123 and 159-169 case state:

Code:
// hack - state name          
case 'state': 
   $dbst1 = new ps_DB();
   $q = "SELECT state_name FROM #__{vm}_state WHERE #__{vm}_state.country_id = ";
   $q .= "(SELECT country_id FROM #__{vm}_country WHERE #__{vm}_country.country_name = '".$dbc->f('country_name')."') ";
   $q .= "AND #__{vm}_state.state_2_code = '".$dbbt->f($field->name)."' ";
   $dbst1->query($q);
   $jglr_state_name=$dbst1->f( 'state_name' );
   echo $jglr_state_name;
   break;
// end hack - state name
Logged
jagular
Newbie
*
Posts: 15

never ending BFU


« Reply #9 on: April 18, 2009, 08:44:43 AM »

/comoponents/com_virtuemart/themes/xxx/templates/order_emails/confirmation_email.tpl.php

customer state name
add on lines 82-92 and 132-142 case state:

Code:
// hack - state name          
case 'state': 
   $dbst1 = new ps_DB();
   $q = "SELECT state_name FROM #__{vm}_state WHERE #__{vm}_state.country_id = ";
   $q .= "(SELECT country_id FROM #__{vm}_country WHERE #__{vm}_country.country_name = '".$dbc->f('country_name')."') ";
   $q .= "AND #__{vm}_state.state_2_code = '".$dbbt->f($field->name)."' ";
   $dbst1->query($q);
   $jglr_state_name=$dbst1->f( 'state_name' );
   echo $jglr_state_name;
   break;
// end hack - state name

vendor state name - TODO
Logged
jagular
Newbie
*
Posts: 15

never ending BFU


« Reply #10 on: April 18, 2009, 11:14:52 AM »

/administrator/components/com_virtuemart/html/order.order_printdetails.php

vendor country name and state name in address

its can be done with skipping ps_vendor class and taking address directly from db

on line 46 comment: ps_vendor::formatted_store_address(true)
and add:

Code:
// hack - vendor address
$dbvndr = new ps_DB;
$q  = "SELECT #__{vm}_vendor.vendor_name, #__{vm}_vendor.vendor_address_1, #__{vm}_vendor.vendor_address_2, #__{vm}_vendor.vendor_zip, #__{vm}_vendor.vendor_city, #__{vm}_vendor.vendor_state, #__{vm}_vendor.vendor_country, #__{vm}_country.country_name, #__{vm}_state.state_name FROM #__{vm}_vendor LEFT JOIN #__{vm}_country ON  #__{vm}_vendor.vendor_country = #__{vm}_country.country_3_code LEFT JOIN #__{vm}_state ON  #__{vm}_vendor.vendor_state = #__{vm}_state.state_2_code";
$dbvndr->query($q);
echo $dbvndr->f("vendor_name")."<br />";
echo $dbvndr->f("vendor_address_1")."<br />";
echo $dbvndr->f("vendor_address_2")."<br />";
echo $dbvndr->f("vendor_zip")."&nbsp;&nbsp;&nbsp;".$dbvndr->f("vendor_city")."<br />";
echo $dbvndr->f("state_name")."<br />";
echo $dbvndr->f("country_name")."<br />";
// end hack - vendor address
   


Logged
jagular
Newbie
*
Posts: 15

never ending BFU


« Reply #11 on: April 18, 2009, 11:21:39 AM »

/comoponents/com_virtuemart/themes/xxx/templates/order_emails/confirmation_email.tpl.php

same way like the above
Logged
Pages: [1]   Go Up
Print
Jump to: