<?php
// $Id: malaysia_88_1.cif,v 1.5 2008/07/10 12:41:06 successideaweb.com Exp $

function malaysia_install() {
  // VALUES = Country ID, Country Name, 2-digit Code, 3-digit Code, File Version
  db_query("INSERT INTO {uc_countries} VALUES (88, 'Malaysia', 'MY', 'MY', 1)");

  db_query("INSERT INTO {uc_zones} (zone_country_id, zone_code, zone_name) VALUES "  
          ."(88, 'JH', 'Johor'),"
          ."(88, 'KD', 'Kedah'),"
          ."(88, 'KN', 'Kelantan'),"
          ."(88, 'KL', 'Kuala Lumpur'),"
          ."(88, 'ML', 'Malacca'),"
          ."(88, 'NS', 'Negeri Sembilan'),"
          ."(88, 'PH', 'Pahang'),"
          ."(88, 'PK', 'Perak'),"
          ."(88, 'PS', 'Perlis'),"
          ."(88, 'PG', 'Penang'),"
          ."(88, 'WP', 'Wilayah Persekutuan'),"
          ."(88, 'SL', 'Selangor'),"
          ."(88, 'TR', 'Terengganu'),"
          ."(88, 'LB', 'Labuan'),"
          ."(88, 'SB', 'Sabah'),"
          ."(88, 'SR', 'Sarawak')");
	
  variable_set('uc_address_format_88',
               "!company\r\n!first_name !last_name\r\n!street1\r\n!street2"
              ."\r\n!city, !zone_code !postal_code\r\n!country_name_if");
}


CommentFileSizeAuthor
#3 malaysia.patch1.34 KBalpritt
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alpritt’s picture

Status: Needs review » Needs work

Id at top is filled in automatically so that line should just read

// $Id$

Country codes are wrong. The code should be 458. And the 3 digit code should be MYS.

There is a helper function called uc_set_address_format() to use instead of the variable set.

Technically this isn't a patch.

najibx’s picture

Title: malaysia country » support country malaysia

Thanks. Not a patch. It just was not in the folder. So I added on my own and actually I was copying USA and didn't read the docs. Just wondering how can I have all the counntry without importing the xx.cif file one by one? Furthermore, I don't see the uc_zones being used like Dependant filed as per country?

It should like below?


<?php
// $Id: malaysia_458_1.cif,v 1.5 2008/07/10 12:41:06 successideaweb.com Exp $

/**
 * First implement hook_install() using the name of the country as the base of
 * the function name.
 */
function malaysia_install() {
  // Make the entry in the country table.
  // VALUES = Country ID, Country Name, 2-digit Code, 3-digit Code, File Version
  db_query("INSERT INTO {uc_countries} VALUES ('458', 'Malaysia', 'MY', 'MYS', 1)");

  // Make the entries in the zones table.  Use %d for the zone_id and the
  // function uc_get_zone_ids($num) as the second argument for db_query() where
  // $num is the number of zones in the INSERT query.
  // VALUES = %d for ID, Parent Country ID, Zone Abbreviation, Zone Name
  db_query("INSERT INTO {uc_zones} VALUES "		  
		  ."(%d, 458, 'JH', 'Johor'),"
          ."(%d, 458, 'KD', 'Kedah'),"
          ."(%d, 458, 'KN', 'Kelantan'),"
          ."(%d, 458, 'KL', 'Kuala Lumpur'),"
          ."(%d, 458, 'ML', 'Malacca'),"
          ."(%d, 458, 'NS', 'Negeri Sembilan'),"
          ."(%d, 458, 'PH', 'Pahang'),"
          ."(%d, 458, 'PK', 'Perak'),"
          ."(%d, 458, 'PS', 'Perlis'),"
          ."(%d, 458, 'PG', 'Penang'),"
          ."(%d, 458, 'WP', 'Wilayah Persekutuan'),"
          ."(%d, 458, 'SL', 'Selangor'),"
          ."(%d, 458, 'TR', 'Terengganu'),"
          ."(%d, 458, 'LB', 'Labuan'),"
          ."(%d, 458, 'SB', 'Sabah'),"
          ."(%d, 458, 'SR', 'Sarawak')",
           uc_get_zone_ids(16));

  // Use uc_set_address_format() with the country ID as the first argument and
  // an address format string as the second.  Documentation on address formats
  // is available at:
  // http://www.ubercart.org/ubercart_users_guide/country_settings#address_format_docs
  uc_set_address_format(458,
    "!company\r\n!first_name !last_name\r\n!street1\r\n!street2"
   ."\r\n!postal_code, !city !zone_code\r\n!country_name_if");
}

/**
* If necessary, implement hook_update() with $version being the only argument.
* Add a new case for each version update, and be sure to always include the
* latest changes in the install function.
*/
function malaysia_update($version) {
  // Use a switch control block for easy file maintenance.
  switch ($version) {
    case 2:
      // Obviously this would be replaced with actual update code.
      drupal_set_message('Performing update 2.');
      break;
  }
}

/**
* If necessary, implement hook_uninstall().  This requires no argument.  The
* store module automatically removes rows from the country and zones tables
* related to the country, and it unsets the address format.  This function is
* only necessary for other things you may have included in your country's
* installation process.
*/
function example_country_uninstall() {
}

?>

alpritt’s picture

Status: Needs work » Needs review
FileSize
1.34 KB

Not sure about how to add new files in patches for bzr, but hopefully this is fine.

Should the zone codes be tested against a payment gateway?

rszrama’s picture

Assigned: najibx » rszrama
Status: Needs review » Fixed

The values should be checked against Wikipedia for the ISO-3166 names and codes. Unfortunately, I didn't do this before replacing the other contributed version of this .cif on UC.org. This file has some names wrong, and one that was totally wrong. I updated the zones and abbreviations based on these two pages on Wikipedia:

http://en.wikipedia.org/wiki/ISO_3166-2:MY
http://en.wikipedia.org/wiki/States_of_Malaysia

I'm adding this to both branches.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

ckng’s picture

Status: Closed (fixed) » Needs review

Reopen, as for the malaysia_458_1.cif included in ubercart, the db_query portion is wrong.

<?php
// Make the entries in the zones table.
-  db_query("INSERT INTO {uc_zones} (zone_id, zone_country_id, zone_code, zone_name) VALUES "
+  db_query("INSERT INTO {uc_zones} (zone_country_id, zone_code, zone_name) VALUES "
          ."(%d, 458, 'JHR', 'Johor'),"
          ."(%d, 458, 'KDH', 'Kedah'),"
?>
YesCT’s picture

Status: Needs review » Fixed

I might be confused, but the recent version I got out of the bazaar dev has that line already correct.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.