Brazil states fixes

This commit is contained in:
Mike Jolley 2013-04-24 15:37:49 +01:00
parent 505170da93
commit efa8d9fe62
5 changed files with 65 additions and 53 deletions

View File

@ -0,0 +1,55 @@
<?php
/**
* Update WC to 2.0.9
*
* @author WooThemes
* @category Admin
* @package WooCommerce/Admin/Updates
* @version 2.0.9
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
global $wpdb, $woocommerce;
// Update brazillian state codes
$wpdb->update(
$wpdb->postmeta,
array(
'meta_value' => 'BA'
),
array(
'meta_key' => '_billing_state',
'meta_value' => 'BH'
)
);
$wpdb->update(
$wpdb->postmeta,
array(
'meta_value' => 'BA'
),
array(
'meta_key' => '_shipping_state',
'meta_value' => 'BH'
)
);
$wpdb->update(
$wpdb->usermeta,
array(
'meta_value' => 'BA'
),
array(
'meta_key' => 'billing_state',
'meta_value' => 'BH'
)
);
$wpdb->update(
$wpdb->usermeta,
array(
'meta_value' => 'BA'
),
array(
'meta_key' => 'shipping_state',
'meta_value' => 'BH'
)
);

View File

@ -89,9 +89,6 @@ function do_install_woocommerce() {
// Clear transient cache
$woocommerce->clear_product_transients();
// Fix the Brazilian states.
woocommerce_update_brazil_states();
// Recompile LESS styles if they are custom
if ( get_option( 'woocommerce_frontend_css' ) == 'yes' ) {
@ -106,7 +103,7 @@ function do_install_woocommerce() {
$current_version = get_option( 'woocommerce_version', null );
$current_db_version = get_option( 'woocommerce_db_version', null );
if ( version_compare( $current_db_version, '2.0', '<' ) && null !== $current_db_version ) {
if ( version_compare( $current_db_version, '2.0.9', '<' ) && null !== $current_db_version ) {
update_option( '_wc_needs_update', 1 );
} else {
update_option( 'woocommerce_db_version', $woocommerce->version );
@ -376,50 +373,4 @@ function woocommerce_default_taxonomies() {
}
}
}
}
/**
* Fix the Brazilian states. Change BH for BA.
*
* @access public
* @return void
*/
function woocommerce_update_brazil_states() {
global $wpdb;
// Fix the billing state for orders.
$orders_billing_state = $wpdb->get_results( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_billing_state' AND meta_value = 'BH'" );
if ( $orders_billing_state ) {
foreach ( $orders_billing_state as $value ) {
update_post_meta( $value->post_id, '_billing_state', 'BA', 'BH' );
}
}
// Fix the shipping state for orders.
$orders_shipping_state = $wpdb->get_results( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_shipping_state' AND meta_value = 'BH'" );
if ( $orders_shipping_state ) {
foreach ( $orders_shipping_state as $value ) {
update_post_meta( $value->post_id, '_shipping_state', 'BA', 'BH' );
}
}
// Fix the billing state for clients.
$clients_billing_state = $wpdb->get_results( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'billing_state' AND meta_value = 'BH'" );
if ( $clients_billing_state ) {
foreach ( $clients_billing_state as $value ) {
update_user_meta( $value->user_id, 'billing_state', 'BA', 'BH' );
}
}
// Fix the shipping state for clients.
$clients_shipping_state = $wpdb->get_results( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'shipping_state' AND meta_value = 'BH'" );
if ( $clients_shipping_state ) {
foreach ( $clients_shipping_state as $value ) {
update_user_meta( $value->user_id, 'shipping_state', 'BA', 'BH' );
}
}
}
}

View File

@ -42,5 +42,10 @@ function do_update_woocommerce() {
update_option( 'woocommerce_db_version', '2.0' );
}
if ( version_compare( $current_db_version, '2.0.9', '<' ) ) {
include( 'includes/updates/woocommerce-update-2.0.9.php' );
update_option( 'woocommerce_db_version', '2.0.9' );
}
update_option( 'woocommerce_db_version', $woocommerce->version );
}

View File

@ -170,6 +170,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
* Fix - Disable autocomplete for checkout fields which refresh totals - no events get fired on autocomplete.
* Fix - Clear rating transients when editing comments.
* Fix - Screen ids when plugin name localised.
* Fix - Brazillian state code BH -> BA. Data update required to update old values in orders.
* Localization - Netherlands, Hungarian, Taiwan, Italian, Spanish updates.
* Other minor fixes and localisation updates.

View File

@ -3,7 +3,7 @@
* Plugin Name: WooCommerce
* Plugin URI: http://www.woothemes.com/woocommerce/
* Description: An e-commerce toolkit that helps you sell anything. Beautifully.
* Version: 2.0.8
* Version: 2.0.9
* Author: WooThemes
* Author URI: http://woothemes.com
* Requires at least: 3.5
@ -37,7 +37,7 @@ class Woocommerce {
/**
* @var string
*/
public $version = '2.0.8';
public $version = '2.0.9';
/**
* @var string