From e48d83f162faca61bfd8270e6c0f2294c57ea2c3 Mon Sep 17 00:00:00 2001 From: Mikhail Kuznetsov Date: Fri, 9 Feb 2024 09:22:41 +0400 Subject: [PATCH 1/3] customer_old --- assets/customer.js | 5 ----- inc/RestApiEndpoints.php | 16 +++++++++------- inc/WooAccount.php | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/assets/customer.js b/assets/customer.js index bd8f33d..799ce0c 100644 --- a/assets/customer.js +++ b/assets/customer.js @@ -15,9 +15,6 @@ jQuery(document).ready(function () { } } - // if (typeof params['card_number'] != 'undefined' && params['card_number'] != null ){ - // } - // Регистрация if (isElemetsExist){ show(document.getElementById('bpwp-verify-start')); @@ -94,7 +91,6 @@ jQuery(document).ready(function () { method: 'POST', beforeSend: function ( xhr ) { show(document.getElementById("loader")); - hide(document.getElementById("bpwp-registration")); hide(document.getElementById("bpwp-verify-start")); hide(document.getElementById("bpmsg")); document.getElementById("bpwpSendSms").disabled = true; @@ -110,7 +106,6 @@ jQuery(document).ready(function () { document.getElementById('bpmsg').innerHTML = response.message; show(document.getElementById('bpmsg')); show(document.getElementById("bpwp-verify-end")); - hide(document.getElementById("bpwp-registration")); document.getElementById("bpwpSendOtp").addEventListener("click", function() { hide(document.getElementById("bpwp-verify-end")); diff --git a/inc/RestApiEndpoints.php b/inc/RestApiEndpoints.php index f593342..c19f6f6 100644 --- a/inc/RestApiEndpoints.php +++ b/inc/RestApiEndpoints.php @@ -116,8 +116,6 @@ public function bpwp_customer_checkcode(\WP_REST_Request $request) 'PUT' ); - do_action('logger', $res); - // Если 204 - успех, создаем клиента: запрос POST /customer, phone обязательно if ($res['code'] == 204) { $response = array( @@ -125,7 +123,8 @@ public function bpwp_customer_checkcode(\WP_REST_Request $request) 'message' => 'Код принят', ); - // TODO: Добавить запрос проверки существования пользвателя в б+ + // Код верный. Запрос проверки существования пользвателя в б+ + // Если такой номер существует, обновляем мета и редиректим $get_customer = bpwp_api_request( 'customer', array( @@ -133,16 +132,19 @@ public function bpwp_customer_checkcode(\WP_REST_Request $request) ), 'GET', ); - + if ($get_customer['code'] == 200) { + + update_user_meta($user_id, 'bonus-plus', $get_customer['request']); $response = array( - 'success' => false, - 'message' => 'Ошибка. Пользователь уже существует!', + 'success' => true, + 'message' => 'Пользователь уже существует!', + 'customer_created' => true, // проверим и редиректим на /my-account/bonus-plus/ ); wp_send_json($response); wp_die(); } - + $customer = bpwp_api_request( 'customer', wp_json_encode( array( diff --git a/inc/WooAccount.php b/inc/WooAccount.php index 2a753fc..a679603 100755 --- a/inc/WooAccount.php +++ b/inc/WooAccount.php @@ -257,7 +257,7 @@ public static function bpwp_render_verify_phone_form($phone) -
+ From 6f9d1454eccfd5321ae67be334d63aa6eadea429 Mon Sep 17 00:00:00 2001 From: Mikhail Kuznetsov Date: Fri, 9 Feb 2024 09:23:51 +0400 Subject: [PATCH 2/3] logger --- inc/ApiHelper.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/inc/ApiHelper.php b/inc/ApiHelper.php index 592dd79..8f683d4 100644 --- a/inc/ApiHelper.php +++ b/inc/ApiHelper.php @@ -117,8 +117,6 @@ public static function bpwp_get_calc_bonusplus_price() 'id' => $product->get_id(), 'quantity' => $quantity ); - do_action('logger', $items); - } // Если находимся в корзине From 48e43b108648ac8b2abc916351d695e50ce06686 Mon Sep 17 00:00:00 2001 From: Evgeniy Rezanov Date: Fri, 9 Feb 2024 12:29:31 +0700 Subject: [PATCH 3/3] change version, fix #42 --- README.md | 5 ++++- bonus-plus-wp.php | 4 ++-- readme.txt | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4a4e4b7..f22e324 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ * Tags: bonus, woocommerce, sync, integration * Requires at least: 4.0 * Tested up to: 6.4.2 -* Stable tag: 2.8 +* Stable tag: 2.9 * Requires PHP: 8.1 * License: GPLv2 or later * License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -92,6 +92,9 @@ PHP Рекомендуем 8.0 и выше # Changelog +## 2.9 +- линковка существующего клиента из б+ https://github.com/evgrezanov/bonus-plus-wp/issues/42 + ## 2.8 - убрали поле "дата рождения" из личного кабинета https://github.com/evgrezanov/bonus-plus-wp/issues/58 - добавлена обработка ошибок при экспорте товаров и категорий https://github.com/evgrezanov/bonus-plus-wp/issues/56 diff --git a/bonus-plus-wp.php b/bonus-plus-wp.php index 8fa6117..ce3ad02 100755 --- a/bonus-plus-wp.php +++ b/bonus-plus-wp.php @@ -14,7 +14,7 @@ * PHP requires at least: 8.1 * WP requires at least: 6.0 * Tested up to: 6.4.2 - * Version: 2.8 + * Version: 2.9 */ namespace BPWP; @@ -27,7 +27,7 @@ class BPWPBonusPlus_Core */ public static function init() { - define('BPWP_PLUGIN_VERSION', '2.8'); + define('BPWP_PLUGIN_VERSION', '2.9'); require_once __DIR__ . '/functions.php'; diff --git a/readme.txt b/readme.txt index 21979ff..681e921 100755 --- a/readme.txt +++ b/readme.txt @@ -92,6 +92,9 @@ PHP Рекомендуем 8.0 и выше == Changelog == += 2.9 = +- линковка существующего клиента из б+ https://github.com/evgrezanov/bonus-plus-wp/issues/42 + = 2.8 = - убрали поле "дата рождения" из личного кабинета https://github.com/evgrezanov/bonus-plus-wp/issues/58 - добавлена обработка ошибок при экспорте товаров и категорий https://github.com/evgrezanov/bonus-plus-wp/issues/56