From c16decd9608406a51145a4f7e69116e50daea83d Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Mon, 12 Mar 2018 11:00:11 +0300 Subject: [PATCH] Fix customers edit --- CHANGELOG.md | 3 +++ woo-retailcrm/retailcrm.php | 50 ++++++------------------------------- woo-retailcrm/uninstall.php | 2 +- 3 files changed, 12 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 261f5bad..5ec4b752 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2018-03-12 v.2.1.1 +* Исправлена ошибка редактирования информации о клиенте + ## 2018-02-26 v.2.1.0 * Переработана механика генерации icml каталога товаров * В icml каталог добавлена выгрузка налоговой ставки diff --git a/woo-retailcrm/retailcrm.php b/woo-retailcrm/retailcrm.php index 9e264925..be34c8ac 100644 --- a/woo-retailcrm/retailcrm.php +++ b/woo-retailcrm/retailcrm.php @@ -1,6 +1,6 @@ orderUpdatePayment($order_id); } -/** - * Update order - * - * @param $meta_id, $order_id, $meta_key, $_meta_value - */ -function retailcrm_update_order($meta_id, $order_id, $meta_key, $_meta_value) -{ - if ( ! class_exists( 'WC_Retailcrm_Orders' ) ) { - include_once( check_custom_orders() ); - } - $order_class = new WC_Retailcrm_Orders(); - - if ($meta_key == '_payment_method') { - $order_class->orderUpdatePaymentType($order_id, $_meta_value); - } - - $address = array(); - - if ($meta_key == '_shipping_first_name') $address['firstName'] = $_meta_value; - if ($meta_key == '_shipping_last_name') $address['lastName'] = $_meta_value; - if ($meta_key == '_billing_phone') $address['phone'] = $_meta_value; - if ($meta_key == '_billing_email') $address['email'] = $_meta_value; - if ($meta_key == '_shipping_city') $address['delivery']['address']['city'] = $_meta_value; - if ($meta_key == '_shipping_state') $address['delivery']['address']['region'] = $_meta_value; - if ($meta_key == '_shipping_postcode') $address['delivery']['address']['index'] = $_meta_value; - if ($meta_key == '_shipping_country') $address['delivery']['address']['countryIso'] = $_meta_value; - if ($meta_key == '_shipping_address_1') $address['delivery']['address']['text'] = $_meta_value; - if ($meta_key == '_shipping_address_2') $address['delivery']['address']['text'] .= $_meta_value; - - if (!empty($address)) { - $order_class->orderUpdateShippingAddress($order_id, $address); - } -} - /** * Update order items * @@ -404,14 +370,14 @@ function update_order($order_id) { add_action('retailcrm_history', 'retailcrm_history_get'); add_action('retailcrm_icml', 'generate_icml'); add_action('retailcrm_inventories', 'load_stocks'); - add_action( 'init', 'check_inventories'); - add_action( 'init', 'register_icml_generation'); - add_action( 'init', 'register_retailcrm_history'); - add_action( 'wp_ajax_do_upload', 'upload_to_crm' ); - add_action( 'wp_ajax_generate_icml', 'generate_icml' ); + add_action('init', 'check_inventories'); + add_action('init', 'register_icml_generation'); + add_action('init', 'register_retailcrm_history'); + add_action('wp_ajax_do_upload', 'upload_to_crm'); + add_action('wp_ajax_generate_icml', 'generate_icml'); add_action('admin_print_footer_scripts', 'ajax_upload', 99); add_action('admin_print_footer_scripts', 'ajax_generate_icml', 99); - add_action( 'woocommerce_created_customer', 'create_customer', 10, 1 ); - add_action( 'woocommerce_checkout_update_user_meta', 10, 2 ); + add_action('woocommerce_created_customer', 'create_customer', 10, 1); + add_action('woocommerce_update_customer', 'update_customer', 10, 1); add_action('woocommerce_update_order', 'update_order', 11, 1); } diff --git a/woo-retailcrm/uninstall.php b/woo-retailcrm/uninstall.php index ae837f38..3113ee68 100644 --- a/woo-retailcrm/uninstall.php +++ b/woo-retailcrm/uninstall.php @@ -15,7 +15,7 @@ * * * @link https://wordpress.org/plugins/woo-retailcrm/ - * @since 2.1.0 + * @since 2.1.1 * * @package RetailCRM */