diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fd3855..094a099 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2019-02-07 3.4.2 +* Исправлено изменение типа оплаты на стороне WC +* Добавлен вывод неактивных типов оплаты в настройках +* Удалена генерация внешнего кода клиента + ## 2019-01-22 v3.4.1 * Исправлена архивная выгрузка клиентов diff --git a/VERSION b/VERSION index 8cf6caf..a423d42 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.4.1 \ No newline at end of file +3.4.2 \ No newline at end of file diff --git a/src/include/class-wc-retailcrm-base.php b/src/include/class-wc-retailcrm-base.php index b02c1ae..724cdea 100644 --- a/src/include/class-wc-retailcrm-base.php +++ b/src/include/class-wc-retailcrm-base.php @@ -537,17 +537,15 @@ if (!class_exists('WC_Retailcrm_Base')) { ); foreach ($wc_payment->payment_gateways() as $payment) { - if (isset($payment->enabled) && $payment->enabled == 'yes') { - $this->form_fields[$payment->id] = array( - 'title' => __($payment->method_title, 'woocommerce'), - 'description' => __($payment->method_description, 'woocommerce'), - 'css' => 'min-width:350px;', - 'class' => 'select', - 'type' => 'select', - 'options' => $payment_option_list, - 'desc_tip' => true, - ); - } + $this->form_fields[$payment->id] = array( + 'title' => __($payment->method_title, 'woocommerce'), + 'description' => __($payment->method_description, 'woocommerce'), + 'css' => 'min-width:350px;', + 'class' => 'select', + 'type' => 'select', + 'options' => $payment_option_list, + 'desc_tip' => true, + ); } } diff --git a/src/include/class-wc-retailcrm-customers.php b/src/include/class-wc-retailcrm-customers.php index 310e622..0cbbc9b 100644 --- a/src/include/class-wc-retailcrm-customers.php +++ b/src/include/class-wc-retailcrm-customers.php @@ -136,7 +136,6 @@ if (!class_exists('WC_Retailcrm_Customers')) : $firstName = $customer->get_first_name(); $data_customer = array( 'createdAt' => $createdAt->date('Y-m-d H:i:s'), - 'externalId' => $customer->get_id() > 0 ? $customer->get_id() : uniqid(), 'firstName' => $firstName ? $firstName : $customer->get_username(), 'lastName' => $customer->get_last_name(), 'email' => $customer->get_email(), @@ -149,6 +148,10 @@ if (!class_exists('WC_Retailcrm_Customers')) : ) ); + if ($customer->get_id() > 0) { + $data_customer['externalId'] = $customer->get_id(); + } + if ($customer->get_billing_phone()) { $data_customer['phones'][] = array( 'number' => $customer->get_billing_phone() diff --git a/src/include/class-wc-retailcrm-history.php b/src/include/class-wc-retailcrm-history.php index 852704e..090ae8c 100644 --- a/src/include/class-wc-retailcrm-history.php +++ b/src/include/class-wc-retailcrm-history.php @@ -411,6 +411,8 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) : } } + $wc_order->save(); + return $wc_order->get_id(); } @@ -643,28 +645,32 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) : ) { $orders[$change['order']['id']]['items'][$change['item']['id']][$fields['item'][$change['field']]] = $change['newValue']; } - } else { - if(isset($fields['delivery'][$change['field']]) && $fields['delivery'][$change['field']] == 'service'){ + } elseif ($change['field'] == 'payments' && isset($change['payment'])) { + if ($change['newValue'] !== null) { + $orders[$change['order']['id']]['payments'][] = self::newValue($change['payment']); + } + } else { + if (isset($fields['delivery'][$change['field']]) && $fields['delivery'][$change['field']] == 'service') { $orders[$change['order']['id']]['delivery']['service']['code'] = self::newValue($change['newValue']); - } elseif(isset($fields['delivery'][$change['field']]) && $fields['delivery'][$change['field']]) { + } elseif (isset($fields['delivery'][$change['field']]) && $fields['delivery'][$change['field']]) { $orders[$change['order']['id']]['delivery'][$fields['delivery'][$change['field']]] = self::newValue($change['newValue']); - } elseif(isset($fields['orderAddress'][$change['field']]) && $fields['orderAddress'][$change['field']]){ + } elseif (isset($fields['orderAddress'][$change['field']]) && $fields['orderAddress'][$change['field']]) { $orders[$change['order']['id']]['delivery']['address'][$fields['orderAddress'][$change['field']]] = $change['newValue']; - } elseif(isset($fields['integrationDelivery'][$change['field']]) && $fields['integrationDelivery'][$change['field']]) { + } elseif (isset($fields['integrationDelivery'][$change['field']]) && $fields['integrationDelivery'][$change['field']]) { $orders[$change['order']['id']]['delivery']['service'][$fields['integrationDelivery'][$change['field']]] = self::newValue($change['newValue']); - } elseif(isset($fields['customerContragent'][$change['field']]) && $fields['customerContragent'][$change['field']]) { + } elseif (isset($fields['customerContragent'][$change['field']]) && $fields['customerContragent'][$change['field']]) { $orders[$change['order']['id']][$fields['customerContragent'][$change['field']]] = self::newValue($change['newValue']); - } elseif(strripos($change['field'], 'custom_') !== false) { + } elseif (strripos($change['field'], 'custom_') !== false) { $orders[$change['order']['id']]['customFields'][str_replace('custom_', '', $change['field'])] = self::newValue($change['newValue']); - } elseif(isset($fields['order'][$change['field']]) && $fields['order'][$change['field']]) { + } elseif (isset($fields['order'][$change['field']]) && $fields['order'][$change['field']]) { $orders[$change['order']['id']][$fields['order'][$change['field']]] = self::newValue($change['newValue']); } - if(isset($change['created'])) { + if (isset($change['created'])) { $orders[$change['order']['id']]['create'] = 1; } - if(isset($change['deleted'])) { + if (isset($change['deleted'])) { $orders[$change['order']['id']]['deleted'] = 1; } } diff --git a/src/readme.txt b/src/readme.txt index a04516b..dce9a9f 100644 --- a/src/readme.txt +++ b/src/readme.txt @@ -45,6 +45,10 @@ API-ключ должен быть для отдельного магазина 2. В появившихся списках справочников настройте соответствие способов доставки и оплаты, а так же статусов заказов. Отметьте галочку "Выгружать остатки", если хотите выгружать остатки из Retailcrm в магазин (подробнее смотрите в описании). == Changelog == += 3.4.2 = +* Исправлено изменение типа оплаты на стороне WC +* Добавлен вывод неактивных типов оплаты в настройках + = 3.4.1 = * Исправлены некоторые ошибки @@ -166,6 +170,10 @@ API-ключ должен быть для отдельного магазина * Исправелены ошибки. == Upgrade Notice == += 3.4.2 = +Исправлено изменение типа оплаты на стороне WC +Добавлен вывод неактивных типов оплаты в настройках + = 3.4.0 = Внедрен Daemon Collector diff --git a/tests/phpunit/test-wc-retailcrm-customers.php b/tests/phpunit/test-wc-retailcrm-customers.php index 1d0e32e..284260a 100644 --- a/tests/phpunit/test-wc-retailcrm-customers.php +++ b/tests/phpunit/test-wc-retailcrm-customers.php @@ -84,7 +84,6 @@ class WC_Retailcrm_Customers_Test extends WC_Retailcrm_Test_Case_Helper $customer_send = $retailcrm_customer->getCustomer(); if ($retailcrm) { - $this->assertArrayHasKey('externalId', $customer_send); $this->assertArrayHasKey('firstName', $customer_send); $this->assertArrayHasKey('createdAt', $customer_send); $this->assertArrayHasKey('email', $customer_send);