Skip to content

Commit

Permalink
Merge pull request #60 from evgrezanov/#47_authorization
Browse files Browse the repository at this point in the history
Версия 2.9
  • Loading branch information
evgrezanov authored Feb 9, 2024
2 parents 20a500c + 48e43b1 commit 8d9692b
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 18 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions assets/customer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down Expand Up @@ -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;
Expand All @@ -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"));
Expand Down
4 changes: 2 additions & 2 deletions bonus-plus-wp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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';

Expand Down
2 changes: 0 additions & 2 deletions inc/ApiHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ public static function bpwp_get_calc_bonusplus_price()
'id' => $product->get_id(),
'quantity' => $quantity
);
do_action('logger', $items);

}

// Если находимся в корзине
Expand Down
16 changes: 9 additions & 7 deletions inc/RestApiEndpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,33 +116,35 @@ public function bpwp_customer_checkcode(\WP_REST_Request $request)
'PUT'
);

do_action('logger', $res);

// Если 204 - успех, создаем клиента: запрос POST /customer, phone обязательно
if ($res['code'] == 204) {
$response = array(
'success' => true,
'message' => 'Код принят',
);

// TODO: Добавить запрос проверки существования пользвателя в б+
// Код верный. Запрос проверки существования пользвателя в б+
// Если такой номер существует, обновляем мета и редиректим
$get_customer = bpwp_api_request(
'customer',
array(
'phone' => $args['phone'],
),
'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(
Expand Down
2 changes: 1 addition & 1 deletion inc/WooAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public static function bpwp_render_verify_phone_form($phone)

<!-- <div id="qrcode" style="display:none;"></div> -->

<div id='bpwp-registration'>
<div id='bpwp-registration' style="display:none;">
<p><?php echo __('Вы еще не зарегистрированы в программе лояльности', 'bonus-plus-wp') ?></p>
</div>

Expand Down
3 changes: 3 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8d9692b

Please sign in to comment.